Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  128] [ 3]  / answers: 1 / hits: 18997  / 13 Years ago, fri, october 28, 2011, 12:00:00

I have the usual unordered list for a navigation menu with submenus...



html:



<ul>
<li><a href=#>Link 1</a></li>
<li>
<a href=#>Link with submenu</a>
<ul>
<li><a href=#>Sublink 1</a></li>
</ul>
</li>
</ul>


All of the links inside of the parent <li> have a border radius. But if the parent <li> has a child <ul>, I don't want the link to have a radius.



I'm currently using this jQuery:



<script>
$(li).has(ul).addClass(sub-radius);
</script>


It works fine except it's targeting the <li>, but I need it to target the child <a> and remove its radius.



Any help would be appreciated.


More From » jquery

 Answers
2

Try this expression:



$(li:has(ul) > a).addClass(sub-radius);


Edit: If you don't want the sub-items to have border-radii, remove the > in the query.


[#89390] Thursday, October 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gordonrockym

Total Points: 95
Total Questions: 115
Total Answers: 95

Location: Iraq
Member since Sat, Apr 16, 2022
2 Years ago
;