我正在使用jQuery ajax从url加载图像,显示它们,然后在每个图像的顶部放置一个按钮。JQuery的div标记在FireFox中有孩子,但不是Chrome
代码工作在Firefox,但在铬,股利父“照片”应该有所有的孩子(一个孩子格“照片”从网址获得每幅图像)为0
我有尝试read()
和load()
,但似乎没有任何工作。如果我在Chrome控制台中运行alert($('#photos').children().size());
,它会返回子项。但在执行时返回0.任何想法?
$(window).load(function()
{
$("p").text("The DOM is now loaded and can be manipulated.");
//returns 0 in chrome, but 10 in firefox
alert($('#photos').children().size());
$('#photos').children().each(function()
{
//do stuff
你还可以添加你的HTML的div在哪里? –
您应该使用property .length来代替:alert($('#photos')。children()。length);如果不能正常工作,您的HTML中出现错误,肯定缺少结束标记 –
烘焙是正确的:听起来像您的标记已经搞乱了,某种程度上FF比Chrome更有前途。 – aefxx