Reputation: 11907
I don't know how to do this: I want change color class = "dropdown-toggle"
when I hover .dropdown-menu li
.dropdown-menu li:hover
(or li > a
) (~
or +
or >
) .dropdown-toggle {...}
- its not working
Can I do it in CSS?
My code follows below:
<li class = "dropdown">
<a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"> Lorem ipsum</a>
<ul class = "dropdown-menu">
<li><a href="video.html"> Hellooooo </a></li>
<li class="divider"></li>
<li><a href="#"> Blablabla </a></li>
</ul>
</li>
Upvotes: 1
Views: 89
Reputation: 181
I think you can also use Jquery for this.
$(document).ready(function(){
var menuItem = $('.dropdown-menu li');
var itemToChange = $('.dropdown-toggle');
menuItem.on('mouseenter', function(){
itemToChange.css('background-color', 'red');
});
menuItem.on('mouseleave', function(){
itemToChange.css('background-color', '');
});
});
Hope this helps.
Upvotes: 1
Reputation: 1413
There is currently no way to select the parent of an element in CSS.
If there was a way to do it, it would be in the CSS selectors specs, either CSS 2 or 3
You'll have to use js to do that.
EDIT: You could use the workaround that @Mr. Alien put in his answer.
Upvotes: 1