Forum Moderators: open

Message Too Old, No Replies

Execute Function on Current Item

         

almo136

9:38 pm on Aug 28, 2009 (gmt 0)

10+ Year Member



I have this code which removes a class from an item on mouse out.

function mouseOut8( ) {
$('.bar8')
.removeClass("barover");
}

I would like to change this so that the class is removed from the item I have just moused out of instead of specifying the exact item. This is so I can use this function for multiple items. I tried replacing the '.bar8' with 'this' but it didn't work.

Thanks.

daveVk

3:59 am on Aug 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would this suffice

function mouseOut( n ) {
$('.bar' + n).removeClass("barover");
}

where call becomes "mouseOut(8)"

you could use ( assuming only one class is involved )

function mouseOut( this ) {
this.className = "";
}