0
我想附上<script>
節點用下面的代碼無法添加腳本節點動態
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$('body').append('<script>alert(\'foo\');</script>');
</script>
</body>
</html>
我想到的代碼
alert('foo');
而添加的執行,但實際上,下面的字符串被添加
');
這裏發生了什麼?
因爲它結束腳本標籤早些時候:http://stackoverflow.com/a/236106/142985的[?我可以創建jQuery腳本標籤( – Nathan
可能重複http://stackoverflow.com/問題/ 1199676 /可,我創建腳本標籤逐的jQuery) – CodingIntrigue