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!
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))")
: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))")
nth-child接受整数而不是字符串。
$("#gig:nth-child(3)")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.