Jquery选择器使用求助?

wgp3033 2010-09-27 02:16:05
<th width="20" bgcolor="#08A4CD"></th>
<th id="tc1" class="theader" onclick="sortTable('name',this.id)">Name</th>
<th id="tc2" class="theader" onclick="sortTable('phone',this.id)">Mobile</th>
<th id="tc3" class="theader" onclick="sortTable('out',this.id)">Out</th>
<th id="tcs" class="theader" onclick="sortTable('in',this.id)">In</th>
<th class="white_10">Actions</th>

现在需要用jquery选择th id 为“tc”开头的对象,同时要排除id=“tcs”的那一项,该怎么做呢?
(已经取得tc开头的行:$("th[id^='tc']"))

谢谢大家!
...全文
89 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgp3033 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 qysnowqy 的回复:]

HTML code

<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript">

function a(){
var ths=$("th[id ^='tc'][id!='tcs']");
……
[/Quote]
你的写法的确正确,谢谢,分给你了
wgp3033 2010-09-27
  • 打赏
  • 举报
回复
本人已经找到正确的写法:
var orderTip = 'tcs';
$("th[id^='tc']").not("[th[id="+orderTip+"]")

帖子关闭
qysnowqy 2010-09-27
  • 打赏
  • 举报
回复

<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript">

function a(){
var ths=$("th[id ^='tc'][id!='tcs']");

alert(ths.length);
for(var i=0;i<ths.length;i++){
alert($(ths[i]).html());
}
}


</script>
</head>

<body onload="a();">
<table>
<tr>
<th width="20" bgcolor="#08A4CD"></th>
<th id="tc1" class="theader" onclick="sortTable('name',this.id)">Name</th>
<th id="tc2" class="theader" onclick="sortTable('phone',this.id)">Mobile</th>
<th id="tc3" class="theader" onclick="sortTable('out',this.id)">Out</th>
<th id="tcs" class="theader" onclick="sortTable('in',this.id)">In</th>
<th class="white_10">Actions</th>
</tr>
</table>


</body>

对了呀,我测试都对了。。。
wgp3033 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 qysnowqy 的回复:]

引用 2 楼 andesen 的回复:

$("th[id='tc'][id!=tcs]")

tcs加上引号就灰常正确了噢=。=
[/Quote]
这是错误的,不起作用,谢谢回复
wgp3033 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 andesen 的回复:]

$("th[id='tc'][id!=tcs]")
[/Quote]

这是错误的,不起作用。谢谢回复
passself 2010-09-27
  • 打赏
  • 举报
回复

$("th[id!='tc']"))

qysnowqy 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 andesen 的回复:]

$("th[id='tc'][id!=tcs]")
[/Quote]
tcs加上引号就灰常正确了噢=。=
andesen 2010-09-27
  • 打赏
  • 举报
回复
$("th[id='tc'][id!=tcs]")
andesen 2010-09-27
  • 打赏
  • 举报
回复
没事常翻API

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧