后工作,但jQuery脚本不适用于新数据。 的代码是像这样的:当我使用.html()放置数据时,jquery脚本不能在使用.html()
<html>
<head>
<script>
$(document).ready(function(){
$("#newhtml").on("click", function(){
alert("I'm the NEW one!");
});
$("#put_new").on("click", function(){
$("#newdiv").html("<input type = 'button' id = 'newhtml' value = 'click on me'/>");
});
});
</script>
</head>
<body>
<div id="newdiv"></div>
<input type="button" id="put_new" value="put new html" />
</body>
</html>
这是一个简单的例子,但有更多的数据我想把我希望新的元素,在这样的脚本工作。 我试图在stackoverflow.com上搜索,但我没有找到任何适用的。 非常感谢。
我已经回答了类似的问题。可能会阐明发生了什么/如何避免它:http://stackoverflow.com/questions/12468847/prototype-js-stops-working-after-adding-jquery-replace-other-jquery-works-ju/12480885 #12480885 – dontGoPlastic 2013-04-23 14:50:54
谢谢,我会看看:) – 2013-04-24 10:06:02