-4

This is what I have tried:

$("#container").replaceWith('<div>Hello</div><script>console.log(a);</script>')

the final result will have no script tag.

for clarity :

replaceWith(content),the content was returned from server ,through ajax.

the javascript has been stripped out,feature or bug?

xiaoyifang
  • 919
  • 12
  • 13

1 Answers1

0

Why would you do that? You already are in JavaScript code. Just do this:

$('#container').replaceWith('<div>Hello</div>');
console.log(a);
Šime Vidas
  • 182,163
  • 62
  • 281
  • 385
  • The content is returned from server throught ajax.and you don't know what the script is .so your answer is not proper.I should describe my question more accurate. – xiaoyifang Jul 03 '13 at 02:18