开发者

JQuery select remove where class != "dgItem"

Hi i want to remove the following

<tr><td style="padding-left:20px;" class="content">

This works fine with

$(".content").first().remove();

But on some of my pages I have this

<tr class="dgItem"><td class="content">

And it gets removed. Is it possible to make the JQuery only select the first开发者_开发知识库 example?


Try this:

Example: http://jsfiddle.net/7c7kD/

$('tr:not(.dgItem) > td.content').remove();

Using jQuery's :not() selector, this will remove td.content elements that are a direct child of a <tr> that does not have the class .dgItem.


Why not just add a second class name to the first type of table column class="content anotherclassname"? then call $(".anotherclassname").remove();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜