js遍历标签:var tdnode=$(‘#groupIdList1‘).children(‘p‘).length;
标签:
原标签:<tr>
<td><span>*</span>已选分组:</td>
<td id=groupIdList1 colspan="2"></td>
</tr>
js要领新增标签: AddGroupId:function(){
var groupId=$(‘#groupId2‘).val().trim();
var groupName=$(‘#groupId2‘).find(‘option:selected‘).text();
var v_content = "<p class=‘groupA‘><span groupId=http://www.mamicode.com/\""+groupId+"http://www.mamicode.com/\" groupName=http://www.mamicode.com/\""+groupName+"http://www.mamicode.com/\">"+groupName+" </span>"+
"<a href=http://www.mamicode.com/\"javaScript:void(0);\" onclick=‘groupAdd.deleteGroupId(this)‘>删除 </a></p>";
$("#groupIdList1").append(v_content);
},
js遍历标签: var tdnode=$(‘#groupIdList1‘).children(‘p‘).length;
var groupIdList="";
for(var i=0;i<tdnode;i++){
if(i<(tdnode-1)){
groupIdList+=($(‘#groupIdList1‘).children(‘p‘).children(‘span‘).eq(i).attr(‘groupid‘)+",");
}else {
groupIdList+=($(‘#groupIdList1‘).children(‘p‘).children(‘span‘).eq(i).attr(‘groupid‘));
}
}
网上其他队友的要领:
原文链接:https://blog.csdn.net/innovationad/article/details/74012292
<table>
<tr>
<td>编号</td>
<td>id</td>
<td>usrName</td>
<td>password</td>
<td>email</td>
<td>地点</td>
<td>addTime</td>
<td>操纵</td>
</tr>
<c:forEach items="${userList}" var="user" varStatus="status">
<tr>
<td>${status.count}</td>
<td>${user.id}</td>
<td>${user.name}</td>
<td>${user.password}</td>
<td>${user.email}</td>
<td>${user.address}</td>
<td>${user.addTime}</td>
<td><button type="button" οnclick="lick(this, this.id)">改削</button><button type="button">删除</button></td>
</tr>
</c:forEach>
</table>
编纂lick()要领
function lick(obj, id) {
var td_content = $(obj).parents("tr").children("td"); //获取当前行的父标签下的所有td值,即上边tr下的所有td值
var content = td_content.eq(0).text(); //获取当前行第一个td的值
var content2 = td_content.eq(1).text(); //获取当前行第二个td的值
//获取td下的input 值
$(td_content.eq(1)).find("input").val()
}
遍历获取html中的标签值
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31589.html