我正在使用 JQuery ajax 从 url 加载图像,显示它们,然后在每个图像的顶部放置一个按钮。
该代码在 Firefox 中工作,但在 chrome 中,应该具有所有子项的 div 父“照片”(从 url 接收的每个图像的一个子 div“照片”)为 0。
我试过read()
and load()
,但似乎没有任何效果。如果我 alert($('#photos').children().size());
在 Chrome 控制台中运行,它会返回孩子。但在执行时它返回 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