I have following very basic code. Please see the snippet below. If you inspect the element Test
, you get follwoing output in firefox and chrome:
<a href="#" onclick="myTestFunction(23, " ku="" nti");"="">Test</a>
A understand, that if I do not escape double quotes, the code will not work. And i also figured out that escaping with backslashes does not work. Instead we should use "
I just what to know, what is the logic browsers treat the js code below and especially i want to know why are there appearing all those extra dobule quotes and =
?
Thank you
$('#container').append('<a href="#" onclick="myTestFunction(23, "ku nti");">Test</a>');
function myTestFunction(){
alert('myTestFunction');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div id="container" ></div>