I don't know if there is a CSS selector can do the same as the line below (jQuery code):
.tab_cadre_central .top:eq(0) table tbody tr td table tbody tr:eq(3)
I have tried in CSS something like this:
.tab_cadre_central .top::nth-child(0) table tbody tr td table tbody nth-child:eq(3) { display:none; }
but it didn't work.
The most basic concept of jQuery is to "select some elements and do something with them." jQuery supports most CSS3 selectors, as well as some non-standard selectors.
jQuery eq() Method The eq() method returns an element with a specific index number of the selected elements. The index numbers start at 0, so the first element will have the index number 0 (not 1).
TD #7. TD #8. Apply three different styles to list items to demonstrate that :eq() is designed to select a single element while :nth-child() or :eq() within a looping construct such as . each() can select multiple elements.
The :eq () selector selects an element with a specific index number. The index numbers start at 0, so the first element will have the index number 0 (not 1). This is mostly used together with another selector to select a specifically indexed element in a group (like in the example above).
Say you don’t need all the methods that are in jQuery API and you would need only a few among them, you could look for alternatives. jQuery is around 250Kb. Maybe if you are looking for a smaller file that does all your needs, you would want to look for jQuery Alternatives. Below is the Different jQuery Alternatives which are as follows: 1.
But I think if you’re going to call yourself a full-stack developer, you should know the basics of CSS. And the basics start with the selector. Disclaimer: jQuery selectors aren’t actually unique to jQuery — they’re actually CSS selectors.
For example, you can select all div s on your page by using the simple selector div. Hey, that was easy! The second way is probably the one you’ll use the most: the class attribute. You can select by class by using a dot (.) , so in the example above, to select the all elements with class section I use .section as a selector.
While jQuery's :eq()
uses 0-based indexing, :nth-child()
uses 1-based indexing, so you need to increment your indexes appropriately:
.tab_cadre_central .top:nth-child(1) table tbody tr td table tbody tr:nth-child(4)
But you should really think about refactoring that selector...
⚠ It's worth noting that although :eq()
and :nth-child()
can behave similarly - they are certainly not the same. :eq()
will select the n+1 th element in the set while :nth-child()
will select all elements in the set that are the n th child of their respective parents. ⚠
<div> <span></span> <span></span> </div> <div> <span></span> </div>
The selector div span:nth-child(1)
will fetch two elements, while div span:eq(0)
will only select one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With