0

I want to change the toggle arrow image based on the particular toggle panel

http://jsfiddle.net/47MRH/1/

based on the click i want to toggle between the right and down arrows

CSS:-

.icon
{
height:14px;
width:14px;
float:left;
position:relative;
margin-right:10px;
background:url("http://glyphicons.com/wp-   content/themes/glyphicons/images/glyphicons_halflings.png") no-repeat;
}

.icon-rightarrow
{
background-position:-456px -72px;
}

.icon-downarrow
{
background-position:-313px -119px;
}
4

2 に答える 2

2

You can do this with the AddClass and RemoveClass functions.

The following will change a right-arrow to a down-arrow:

$("#MyElementId").removeClass("icon-rightarrow");
$("#MyElementId").addClass("icon-downarrow");

Here is your updated example

于 2013-02-18T11:16:03.113 に答える
1

Add this line: http://jsfiddle.net/47MRH/2/

j(this).closest('li').find('.icon')
                     .toggleClass('icon-rightarrow, icon-downarrow');

use .toggleClass() to toggle between the classes to right and down arrow icon.

于 2013-02-18T11:16:57.653 に答える