不是这样的。页面中动态引入html片段,在引入的页面中,无法使用html片段中的元素加上each函数。如下
$('#aa').load("menu.html"); // menu.html中有.menu_item元素
$(".menu_item").each(function(){ // 失效
alert($(this).text());
});
【 在 dxef 的大作中提到: 】
: each是可以操作动态添加的元素的,比如下面这个示例,不知道你遇到的问题是什么?
: <!doctype html>
: <html>
: ...................
--
FROM 119.184.121.*