【问题标题】:toggle arrow image change切换箭头图像更改
【发布时间】:2013-02-18 19:25:13
【问题描述】:

我想根据特定的切换面板更改切换箭头图像

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

基于点击我想在向右和向下箭头之间切换

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

【问题讨论】:

    标签: jquery css


    【解决方案1】:

    您可以使用AddClassRemoveClass 函数来做到这一点。

    以下将右箭头更改为向下箭头:

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

    Here is your updated example

    【讨论】:

      【解决方案2】:

      添加这一行:http://jsfiddle.net/47MRH/2/

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

      使用.toggleClass()toggle between the classesrightdown 箭头图标。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-12-14
        • 2021-03-01
        • 1970-01-01
        • 2016-07-04
        • 1970-01-01
        • 1970-01-01
        • 2015-11-23
        相关资源
        最近更新 更多