我正在使用 jQuery 并尝试在单击时交换图像样式。我正在将 .tabs 用于多页表单,并希望在单击该页面时调用一个事件来换出图像类。有点像表格流程完成状态。像面包屑类型。我的代码如下。任何朝着正确方向的帮助将不胜感激。-谢谢
JS:
$(function () {
$("#nav-ul li a").on("click", function (e) {
e.preventDefault();
$('img#no-1').removeClass("nav-number");
$(this).children('img').addClass("nav-number-active")
});
});
HTML:
<div id="nav-Container">
<ul id="nav-ul">
<li>
<a href="#page-1" class="nav-a-link">General Information
<img src="images/no-images/img-no-1.png" id="no-1" class="nav-number" />
</a>
</li>
<li>
<a href="#page-2" class="nav-a-link">Setpoints
<img src="images/no-images/img-no-2.png" id="no-2" class="nav-number" />
</a>
</li>
<li>
<a href="#page-3">Call Flow Structure
<img src="images/no-images/img-no-3.png" id="no-3" class="nav-number" />
</a>
</li>
<li>
<a href="#page-4">Summary
<img src="images/no-images/img-no-4.png" id="no-4" class="nav-number" />
</a>
</li>
</ul>
</div>
样式表:
.nav-number{
margin:0px;
float:right;
padding:10px 0px 0px 13px;
opacity:0.4;
border:0px;
}
.nav-number-active{
margin:0px;
float:right;
padding:10px 0px 0px 13px;
border:0px;
}