开发者

jQuery: Selecting td without a specific element

I am trying to style some table cells that do not have an input tag in them. I have a jsFiddle set up, so you're welcome to make changes there.

As you can see, the top row has an input that is also being affected by the jquery-enable开发者_如何转开发d css, so my selector isn't quite right.

Elsewhere in my site I'm using this:

$('#content p a:not([href^="http"])').addClass("internalLink");

to (successfully) find internal links in my text, so I was basing the table cells selector on that, but I don't understand where I'm going wrong...

Thanks for anyone's help!


http://jsfiddle.net/JsTjK/9/

$('#hostingInfo td:not(:has(input))').css('text-align', 'right');


Here you go

Working demo

$('#hostingInfo tr').filter(function(){
   return $(this).find("input").length == 0;
}).find("td").css('text-align', 'right');


Try this:

$('#hostingInfo td').not(':has(input)').css('text-align', 'right');

You can use not() method to select everything that does not satisfy a selector in jQuery.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜