JS:
$(document).ready(function(){
$("#loader").load("external.html");
$("#buttonClickText").live('click', function() {
$("#buttonClickText").text("Text changed after button click.");
});
// MYSTERY FUNCTION
$("#pageLoadText").text("Text changed after external HTML was loaded.");
//
});
外部 HTML:
<div id="buttonClickText">
This text changes when clicked.
</div>
<div id="pageLoadText">
This text should have changed when external HTML was loaded, but didn't.
</div>
主 HTML(仅显示相关标签):
<div id="loader"></div>
另外,我知道 .live() 已被 jQuery 1.7+ 弃用,我猜使用 .on() 的解决方案将是相似的
谢谢!