【发布时间】:2011-10-28 20:38:33
【问题描述】:
我有一个包含无序列表的 DIV。我想复制一份,重新格式化一下,然后重新插入到 DOM 中。这很好用,在 IE 上执行(目前在 8 和 9 中测试过),其中元素的副本似乎是实时的,而不是副本。
会发生什么:
var target = $('.cities').eq(0) //grab my list
var $bigList = $(target).find('li') // grab all the list items
alert($bigList.eq(0).html()) // this displays the first list item, no problem
$(target).html(emptyList) // I put in a bunch of placeholder HTML
alert($bigList.eq(0).html()) // EMPTY on IE, same as first alert() on all others
似乎$bigList 仍然指向 DOM,而不是被复制为一个值。我该如何解决这个问题?
【问题讨论】:
标签: javascript jquery html internet-explorer