Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Animate - border color and width

Tags:

jquery

I cannot seem to get this jQuery animation working for applying a border to an image on mouseenter:

<div>
    <img src="http://25.media.tumblr.com/acc96259d6b2678985052c33e05a3062/tumblr_mkv9fhDBDS1rmc58qo1_500.jpg" />
</div>

jQuery

$('div img').mousenter(function(){
    $(this).css({"border": "0px solid #f37736"}).animate({
        'borderWidth': '4px',
        'borderColor: '#f37736'
    },500);
}).mouseleave(function(){
     $(this).animate({
        'borderWidth':'0px',
        'borderColor:'#f37736'
    },500);
});

I also tried removing the CSS part for the jQuery, but does not work either

like image 926
DextrousDave Avatar asked May 28 '13 13:05

DextrousDave


1 Answers

Change your jQUERY to this

$('div img').mouseenter(function(){
    $(this).css("border", "0px solid #f37736").animate({
        'borderWidth': '4px',
        'borderColor': '#f37736'
    },500);
}).mouseleave(function(){
     $(this).animate({
        'borderWidth':'0px',
        'borderColor':'#f37736'
    },500);
});
like image 190
Suthan Bala Avatar answered Nov 15 '22 22:11

Suthan Bala