<table>
<tbody>
<tr contactName="1">
<td>fda</td>
</tr>
<tr contactName="2">
<td>fda</td>
</tr>
</tbody>
</table>
$(".edit").click(function(){
index=$(this).parents("tr").index();
})
$("#contactTable tbody tr[contactName='1']").not(":eq("+index+")").length查找所有tr中是否包含contactname=1的值,但要我要排除tr中eq为index索引
上面的jq代码并不会达到我的要求,请哪位帮忙看下,谢谢了
index=$(this).parents("tr").index();
$("#contactTable tbody tr[contactName='1']").not(":eq("+index+")").length
})
$(function(){
var o=$("#tabletest tbody tr").not($("#tabletest tbody tr").eq(1)).filter("[contactName='1']")
o.each(function(){
alert($(this).html())
})
})
</script>
<table id="tabletest">
<tbody>
<tr contactName="1">
<td>1</td>
</tr>
<tr contactName="1">
<td>2</td>
</tr>
<tr contactName="2">
<td>3</td>
</tr>
<tr contactName="1">
<td>4</td>
</tr>
</tbody>
</table>
$(function(){
var o=$("#contactTable tbody tr").not($("#contactTable tbody tr").eq(1)).filter("[contactName='1']")
//o.length就是你要的长度了,这是each给你看一下取到的对象对不对
o.each(function(){
alert($(this).html())
})
})
</script>
<table id="contactTable">
<tbody>
<tr contactName="1">
<td>1</td>
</tr>
<tr contactName="1">
<td>2</td>
</tr>
<tr contactName="2">
<td>3</td>
</tr>
<tr contactName="1">
<td>4</td>
</tr>
</tbody>
</table>
var o=$("#contactTable tbody tr").not(function(i){return i==index}).filter("[contactName='1']")