Skip to content Skip to sidebar Skip to footer

How To Remove Hover State When The Element Moves

I have this example:
http://jsfiddle.net/VKwjD/20/ if you hover the same square, his color change

Solution 1:

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';
        }
    });        
});

Post a Comment for "How To Remove Hover State When The Element Moves"