【发布时间】:2012-10-18 20:57:44
【问题描述】:
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>
另外,我知道 jQuery 1.7+ 不推荐使用 .live(),我猜使用 .on() 的解决方案会类似
谢谢!
【问题讨论】:
标签: html load external jquery jquery-on