You need to add a class using jQuery to each link "Section Name" of the first line of nesting, regardless of the nesting levels of the tree. Simple language - you need to select only the name of each section. The pseudo-classes :first and :first-child do not help, since they add a class to either the first element or all links in the tree. Here is an example.
- jsfiddle.net/soledar10/fyta3p4d - soledar10
- > direct descendants - soledar10
- soledar10, thanks a lot! And I broke my head. So simple ... - Torawhite
|
1 answer
A similar question, only there it was not necessary to add the class, but to display it ( link ).
Brute force solution:
$(document).ready(function() { var parent = $('ul:first'), highlight = $('li a', parent); // ссылки со всех линий вложенности highlight = highlight.filter(function(){ return !$('ul', parent).has($(this)).length; // проверка вложенности }); highlight.addClass('link'); }); |