文件:a.html
...
// JavaScript function
function abc( id )
{
$("#body").load( "b.html" );
var m = document.getElementById( "bbb" );
// id and tag is removed after load, bbb can not be found. m is null
if (m != null)
{
m.innerText = "XYZ";
}
}
...
// HTML
<div id="body">
</div>
文件:b.html
<div id="bbb" tag="bbb" onclick="DoOnClick()">
</div>
tag 和 id 在 jQuery.load 后被删除。 加载后如何保留 id 或标签?
最佳答案
尝试类似的东西 - LOAD
如果提供了“完整”回调,则会在执行后处理和 HTML 插入后执行。
function abc( id )
{
$("#body").load( "b.html",function(){
var m = document.getElementById( "bbb" );
// id and tag is removed after load, bbb can not be found. m is null
if (m != null)
{
m.innerText = "XYZ";
}
});
}
关于javascript - id 和标签在 jQuery 加载后被删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24696496/