$(document).ready(function() { $("#form1").each(function(i) { var a = $(this).ID; }); });
根据楼主的意思, 是在form中搜索input标签$("form").find("input").each(function(){ var id = $(this).attr("id"); switch($(this).attr(你的自定属性)){ case "a": //调用你的a方法 //id传入 break; case "b": //调用你的b方法 break; } });
$(document).ready(function() {
$("#form1").each(function(i) {
var a = $(this).ID;
});
});
var id = $(this).attr("id");
switch($(this).attr(你的自定属性)){
case "a":
//调用你的a方法
//id传入
break;
case "b":
//调用你的b方法
break;
}
});