Javascript 删除上次单击的span上的图标 问题
我试图仅在上次单击的Javascript 删除上次单击的span上的图标 问题,javascript,jquery,font-awesome,Javascript,Jquery,Font Awesome,我试图仅在上次单击的span上隐藏字体“plus”图标。突出显示并在没有活动类的span上显示它,但现在它正在删除两个span上的图标,并且在添加活动类后不会显示 JSFiddle: scripts.js index.html 下一层教堂主楼Shoreditch早午餐成衣。Chia腌制了什么,蓝瓶农场到餐桌信使包Neutra disrupt你可能没听说过keytar dreamcatcher生物柴油班卓琴开襟羊毛衫。事实上,陈词滥调你可能还没听说过他们在上面纹了一只鸟,克雷·布什维克讽刺自拍《合
span上隐藏字体“plus”图标。突出显示并在没有活动类的span上显示它,但现在它正在删除两个span上的图标,并且在添加活动类后不会显示
JSFiddle:
scripts.js
index.html
下一层教堂主楼Shoreditch早午餐成衣。Chia腌制了什么,蓝瓶农场到餐桌信使包Neutra disrupt你可能没听说过keytar dreamcatcher生物柴油班卓琴开襟羊毛衫。事实上,陈词滥调你可能还没听说过他们在上面纹了一只鸟,克雷·布什维克讽刺自拍《合成洛莫酒吧》。混乱的奥斯汀占领运动
您可以使用以下功能:
$(".highlight").click(function() {
$(".highlight").removeClass("active"); // Remove active class from spans
$(".fa-plus-circle").show();
$(".info").fadeIn(); // Fade in the info box to the left
var active = $(this).hasClass("active");
/*if (active) {
$(this).find(".fa-plus-circle").hide(); // Remove plus sign on active span
} else {
$(this).find(".fa-plus-circle").show();
}*/
$(this).addClass("active"); // Add an active class to span just
$(this).find(".fa-plus-circle").hide();
});
这里的示例:您可以使用:
$(".highlight").click(function() {
$(".highlight").removeClass("active"); // Remove active class from spans
$(".fa-plus-circle").show();
$(".info").fadeIn(); // Fade in the info box to the left
var active = $(this).hasClass("active");
/*if (active) {
$(this).find(".fa-plus-circle").hide(); // Remove plus sign on active span
} else {
$(this).find(".fa-plus-circle").show();
}*/
$(this).addClass("active"); // Add an active class to span just
$(this).find(".fa-plus-circle").hide();
});
这里的例子:我修改了你的JSFIDLE,请检查它是否按照你的预期工作,并让我知道:是的,这正是我想要它做的。我已经发布了答案我修改了你的JSFIDLE,请检查它是否按照你的预期工作,并让我知道:是的,这正是我想要它做的。我已经发布了答案
$(".highlight").click(function() {
$(".highlight").removeClass("active"); // Remove active class from spans
$(".fa-plus-circle").show();
$(".info").fadeIn(); // Fade in the info box to the left
var active = $(this).hasClass("active");
/*if (active) {
$(this).find(".fa-plus-circle").hide(); // Remove plus sign on active span
} else {
$(this).find(".fa-plus-circle").show();
}*/
$(this).addClass("active"); // Add an active class to span just
$(this).find(".fa-plus-circle").hide();
});