I have this HTML
<div id='navContainer'> <ul> <li class='selected'><a href='#'>Home</a></li> <li><a href='#'>Services</a></li> </ul> </div>
And I want to change the top border of the li next to the selected one (in this case ‘Services’). I have this jQuery but it does not work.
$(document).ready(function(){ alert($('#navContainer .selected').next().html()); // This alerts: <a href='#'>Services</a> $('#navContainer .selected').next().css('border-top-color','#7d7d7d'); // This doesn't do anything });
Am I doing something wrong?
Thanks in advance!
Are you trying to change the top border or the background color? Fix your question.
Your example works for me. Here’s my full test:
The second element’s background color turns red.