用jquery 改变文本框的id,为啥前4个可以改变,后面的就变不了了 - Web 开发 / Ajax
- JScript code
//复制一行 var tr = $("#copyClass tr").eq(1).clone(); tr.find(":text").eq(0).attr("id","student_rqbbid_morev_"+y);//改变id tr.find(":text").eq(0).attr("id","student_rqbbid_moren_"+y);//改变id tr.find(":text").eq(1).attr("id","student_class_morev_"+y);//改变id tr.find(":text").eq(1).attr("id","student_class_moren_"+y);//改变id tr.find(":text").eq(2).attr("id","student_xuefeibz_moren_"+y);//改变id tr.find(":text").eq(2).attr("id","student_xuefeibz_morev_"+y);//改变id tr.find(":text").eq(3).attr("id","student_yh_moren_"+y);//改变id tr.find(":text").eq(3).attr("id","student_yh_morev_"+y);//改变id tr.find(":text").eq(4).attr("id","student_yhje_moren_"+y);//改变id tr.find(":text").eq(4).attr("id","student_yhje_morev_"+y);//改变id tr.find(":text").eq(5).attr("id","student_xfys_moren_"+y);//改变id tr.find(":text").eq(5).attr("id","student_xfys_morev_"+y);//改变id tr.find(":text").eq(6).attr("id","student_xfss_moren_"+y);//改变id tr.find(":text").eq(6).attr("id","student_xfss_morev_"+y);//改变id tr.appendTo("#copyClass");
从eq(4)到eq(6)就变不了了??为什么,怎么输出查看结果呀?
[解决办法]
tr.find(":text").eq(4)?
你先查一下tr.find(".text").length。
那么长的代码为什么不能用数组和for语句来?
[解决办法]
你alert(tr.html()) 看看输出结果是什么