I have applied a style as follows and it works great for me:
$("td[id='cellId']").css("text-align", "left");
However, I need that style to only be applied to the TD IF it contains textboxes and NOT radio buttons.
I have searched hi and low, but find()
, contains()
and the likes, does not seem to be working.
If you need to filter TD-s which contain textboxes and NOT radio buttons, then you need to use
:has
and:not
combination:Here is a snippet where filtered cells got a red background. You can apply any style to them.
First note that your
$("td[id='cellId']")
is rather surprising: I may guess that you have somevar cellId
which contains the cell id, so you should use$('#' + cellId)
.Now, since you didn't precise about the (eventually) nested elements in the td, we must ensure there is no radio button inside it.
Anyway let's suppose we have
var cellElem
that you've populated as needed (may be like showed above).So you may use something like this:
Use the
:has()
selector to match elements that contain other elements.