0

I have this example:

<div class="container">
    <div class="bp"></div>
</div>

http://jsfiddle.net/VKwjD/20/

if you hover the same square, his color changes; if you click, the parent size changes so the square move.

My problem is: If you don't move your mouse after the click, the square stays in the hover state... Why ? It's possible to remove this state after the click? without moving the mouse...

Thank you for your help

1 Answers1

-2

HTML:

<div class="container">
    <div class="bp" id="bp"></div>
</div>

CSS:

.container {
    background: #FF0000;
    width: 200px;
    height: 200px;
    position: relative;
}    
.container.hide {
    width: 50px; 
}        
.bp {
    background: #00FFFF;
    width: 30px;
    height:30px;
    top:0px;
    right:0px;
    position:absolute;
    cursor: pointer;
}    
.bp:hover{
    background: #0000FF!important;
}

JavaScript:

$(document).ready(function() {
    $('.bp').click(function() {        
        if($('.container').hasClass('hide')) {
            $('.container').removeClass('hide');
            var l1 = document.getElementById('bp');
            l1.style.background = '#00FFFF';            
        }
        else {
            $('.container').addClass('hide');
            var l1 = document.getElementById('bp');
            l1.style.background = '#0000FF';
        }
    });        
});
codingrose
  • 15,563
  • 11
  • 39
  • 58
Dipak
  • 115
  • 1
  • 9