$(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()
謝謝!
謝謝,我知道這將是一個簡單的答案,但我無法弄清楚 –