Reputation: 17
In jQuery, I made a complex selector but it's not working. Could someone tell me what I'm doing wrong?
$("#gig:nth-child('3'):contains(:not('a'))")
Thanks!
Upvotes: 1
Views: 139
Reputation: 27637
:contains('a')
matches elements containing the letter a
in its text. If you're looking for elements without a child <a>
link
$("#gig:nth-child(3):not(:has(a))")
Upvotes: 1
Reputation: 723448
If you're trying to select an element whose text doesn't contain the letter a, you'll want to switch the positions of :contains()
and :not()
as :contains()
isn't supposed to contain another selector. Try this:
$("#gig:nth-child(3):not(:contains('a'))")
If you meant an a
element rather than the letter a, use :has()
:
$("#gig:nth-child(3):not(:has(a))")
Upvotes: 2