0

In a span tag, I have a function where parameter value can be a string with single quote.

But even if I escape single quote by antislash, browser console displays error.

Here my code :

<html>
<body>

<script type="text/javascript">

function check(val)
{
    console.log(val);
}

</script>   

<span contenteditable onkeydown='check("foo\'foo");'>abc</span>

</body>
</html>

Why the escaping doesn't work ?

totoaussi
  • 712
  • 1
  • 11
  • 27

1 Answers1

3
<span contenteditable onkeydown="alert('foo\'foo');">abc</span>

will do the trick.

Cristopher
  • 325
  • 1
  • 11