jquery - 切换箭头图像更改

标签 jquery css

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

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

最佳答案

您可以使用 AddClass 来做到这一点和 RemoveClass功能。

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

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

Here is your updated example

关于jquery - 切换箭头图像更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14934897/

相关文章:

html - CSS - IE7 忽略第一个列表项的边距?

html - 焦点 'centers' 输入上的固定高度输入字段

javascript - 防止 jQuery one() 函数上的点击跳转

javascript - JQuery:如果attr(left)等于0px怎么写?

javascript - 捕获 Bootstrap slider 上的下降值(不是拖动)

css - 完美中心的内容栏,附有左右栏

javascript - 用于检测浏览器宽度和高度的 JS 在 Chrome 和 Safari 中有效,但在 IE9 或 FF9 中无效

javascript - jQuery ajax 从另一台服务器加载 html

jQuery 数字格式 - 如何阻止字母接受?

php - 基于浏览器的游戏 map