Reputation: 2043
I have very small thing to do, That is:
I have two divs, called "first" and "second". Initially div "second" is hidden and div "first" is visible on page load. Once I hover on div "first" the "second" div is visible and "first" is hidden. Now here I want it so then when I mouse out from "second" div the "first" div should be visible and "second" should hide. My problem is that the first time I hover mouse on "first" div, the "second" goes visible but later on mouse over does not work and "second" div is not hidden.
$('#first').hover(function(){
$('#second').hide();
});
$('#second').onmouseover(function(){
$('#second').hide();
$('#first').show();
});
<div id="first"> First </div>
<div id="second"> Second </div>
Upvotes: 0
Views: 204
Reputation: 2180
$('#first').on('mouseover', function(){
$('#second').show();
$('#first').hide();
});
$('#second').on('mouseout', function(){
$('#first').show();
$('#second').hide();
});
Upvotes: 1
Reputation: 38112
There is no onmouseover
function, you can use mouseover
or .on('mouseover',.....)
You can do like this:
$('#first').on('mouseover', function(){
$('#second').show();
$('#first').hide();
});
$('#second').on('mouseout', function(){
$('#first').show();
$('#second').hide();
});
Upvotes: 0