我是jQuery的新手,熟悉PHP和CSS.我有嵌套的,动态生成的div,我想发送(id)到服务器端脚本来更新数字.我想检查.content类中的所有内容.只有带有id的div才能被发送处理; 但是我在制作递归子()检查时遇到了麻烦...这是我能做的最好的(非递归):
$(".content").children().each(function() {
if ($(this).attr('id').length == 0) {
$(this).children().each(function() {
if ($(this).attr('id').length == 0) {
$(this).children().each(function() {
if ($(this).attr('id').length == 0) {
$(this).children().each(function() {
alert($(this).attr('id'));
});
}
});
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
它只是提醒()它们所在级别的所有内容的id.必须有更好的方法来做到这一点...提前感谢您的任何建议.-Justin