Reputation: 31
I have a div with style="display:none"
. On mouse hover on a link I want to show it by adding a class with display=block
but it is not working.
Upvotes: 1
Views: 255
Reputation: 57322
you need to use !important
in class .Check this awesome answer to see how !important
works
/*html*/
<div class="first" style="display:none;">sdfirst</div>
<div class="second" >second</div>
/*jquery*/
$(".second").mouseover(function() {
$(".first").addClass("ss");
})
/*css*/
.ss{display:block !important;}
Upvotes: 3
Reputation: 1046
use this code
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body><div id="main">
Mouse Over (click here for event)
<div id="div1" style="display:none">hello how are you</div>
</div><script>
var i = 0;
$('#main').mouseover(function() {
$('#div1').css('display','block');
}).mouseout(function(){
$('#div1').css('display','none');
});
</script></body>
</html>
for add the you can use
$('#div1').addClass("className");
Upvotes: 0