Remove second class from an element and add another class

Posted by rahul on Stack Overflow See other posts from Stack Overflow or by rahul
Published on 2009-09-18T11:19:47Z Indexed on 2010/05/04 4:08 UTC
Read the original article Hit count: 265

Filed under:
|
|

Hi,

$(document).ready ( function () {
    $(".MenuItem").mouseover ( function () {
        // Remove second class and add another class [ Maintain MenuItem class ]
        // Eg: For div1 remove Sprite1 and then add Sprite1Dis and for div2 
        // remove Sprite2 and add Spprite2Dis 
    });
    $(".MenuItem").mouseout ( function () {
        // Reverse of mouseover. ie Remove Sprite1Dis and add Sprite1
    });
});

<div id="div1" class="MenuItem Sprite1">
&nbsp;
</div>

<div id="div2" class="MenuItem Sprite2">
&nbsp;
</div>

<div id="div3" class="MenuItem Sprite3">
&nbsp;
</div>

<div id="div4" class="MenuItem Sprite4">
&nbsp;
</div>

<div id="div5" class="MenuItem Sprite5">
&nbsp;
</div>

<div id="div6" class="MenuItem Sprite6">
&nbsp;
</div>

My problem is listed as comment inside the code section. What will be the easiest way to achieve this?

Thanks in advance

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about addclass