有一个鳕鱼http://jsfiddle.net/VWCnd/8/。如何执行以下操作:当按下“全部打开”时,所有 + 更改为 - ?
html:
<a onclick=$("div[class^='spoiler_toggle']").show() style="cursor:pointer; text-decoration: underline;">expand all</a>
/
<a onclick=$("div[class^='spoiler_toggle']").hide() style="cursor:pointer; text-decoration: underline;">close all</a>
<a href="" class="spoiler_title">Title<span class="sp_ind">+</span></a>
<div class="spoiler_toggle">
<div class="spoiler_bg">
<p>
artile
</p>
</div>
</div>
CSS:
.spoiler_title {
display:block;
background-color: #551A8B;
color: #fff;
padding: 10px 10px;
}
.spoiler_toggle {
display:none;
}
.sp_ind{
float: right;
margin-right: 10px;
}
.spoiler_bg {
background: #9C6AC9;
padding: 1px 10px;
}
JS:
$(document).ready(function(){
$('.spoiler_title').click(function(){
$(this).find(".sp_ind").text(($(this).find(".sp_ind").text() == '+' ? '-' : '+'))
$(this).parent().children('div.spoiler_toggle').toggle();
return false;
});
});
谢谢你们帮助菜鸟:)