Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Joel Godoy
15,429 PointsUsing jQuery to modify bootstsrap nav
I'm using bootstrap to build a basic navigation and when i use jQuery to modify the css on hover it targets every link item as a group. The only solution i can find is to create a unique class or ID for each and create a function for each individual link item. Is there a better way? question
$(document).ready(function(){
$('.nav-item a').mouseenter(function(){
$('.nav-item a').css('color','red');
})
$('.nav-item a').mouseleave(function(){
$('.nav-item a').css('color','black');
})
});
1 Answer
trio-group I.AM
25,713 PointsHey!
I believe that your selector
$('.nav-item a')
might be returning an array that contains all links. I can't be sure since I don't know how you've structured your markup. Try storing your selection in a variable and then use a for loop to iterate through the array items (if it really is an array).
Hope this helps... somehow.