我在 Chrome 上遇到了这个奇怪的问题 - 在我的页面上,我使用 Mootools 注入(inject)元素,特别是包含 jwplayer 视频的灯箱。 chrome 上的问题是引用一个元素,即。 $('grid_01');我第二次点击它时返回 null。为了解决这个问题,我尝试测试该元素是否为 null 并重新注入(inject)它
var ss = $('holderdiv');
var x = $('mb_inline_0_-1');
if(x == null)
{
var el = new Element("div", {id: "mb_inline_0_-1"});
//if this line below runs without error...
ss.inject(el);
}
//.........why would x2 be null?
var x2 = $('mb_inline_0_-1');
Chrome 表示其为空。我可以做些什么来确保 DOM 更新吗?
谢谢
最佳答案
您的意思是使用抓取,而不是注入(inject)。
ss.grab(el); // Or el.inject(ss);
您的代码将 ss 注入(inject)到 el 中,而 el 从未附加到 DOM。
关于javascript - 在 Chrome 下 - Mootools 注入(inject)因 null 元素而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8903187/