我有这两个功能,我想应用于同一次点击(我确实在点击功能中都有它们,结果相同......图像切换每次都有效,但显示/隐藏切换(“optionToggle”)仅第一次工作。两者分别工作正常
提前致谢
function imageToggle() {
var img = $('.choices').find('.btn').children().children('img');
img.toggle(function () {img.attr("src","images/misc/dotr-add.png");},
function () {img.attr("src","images/misc/dotr-minus.png");}
);
}
function optionToggle() {
var option = $('.choices').find('.btn').closest('.dishActions').children('.option');
option.toggle();
}
$('.btn').click(function() {
optionToggle();
imageToggle();
});
这是代码 -
<div class="dishActions">
<!-- DISH CHOICE -->
<div class="choices">
<div class="btn">
<a href="#">
<img src="images/misc/dotr-add.png" height="40" width="40" alt="button up" border="0" />
</div>
<div class="choicesTxt">Choices </div>
</div>
<!-- DISH OPTIONS -->
<div class="option">