Javascript 关闭当前div并打开另一个div
我感觉好几个小时了。 我不能告诉我的脚本,当我按下一个按钮时,必须先关闭显示器,然后再打开新的,有人帮我吗Javascript 关闭当前div并打开另一个div,javascript,Javascript,我感觉好几个小时了。 我不能告诉我的脚本,当我按下一个按钮时,必须先关闭显示器,然后再打开新的,有人帮我吗 $(document).ready(function() { $('.testoprodotto').addClass("hidden"); $('.testoprodotto').on('click', function() { if ($(this).hasClass("hidden")) { $(this).removeCla
$(document).ready(function() {
$('.testoprodotto').addClass("hidden");
$('.testoprodotto').on('click', function() {
if ($(this).hasClass("hidden")) {
$(this).removeClass("hidden").addClass("visible"); // Dropdown
$(this).find('.more').hide().siblings('.less').show(); // Button
} else {
$(this).removeClass("visible").addClass("hidden"); // Dropdown
$(this).find('.more').show().siblings('.less').hide(); // Button
}
});
});
一种方法是在可见的屏幕上单击鼠标
$('.testoprodotto').on('click', function() {
if ($(this).hasClass("hidden")) {
$('.testoprodotto.visible').click();
$(this).removeClass("hidden").addClass("visible");
/* rest of your code */
问题不是很清楚。。。你想要什么?当你点击一个div(你想让它显示)时,你想隐藏所有已经打开的div吗?jQuery中有一个显示/隐藏函数,比如toggle也…:)不需要添加/删除类…这应该是上面对OP的一个注释,使用类,它可以使用CSS做其他事情,而不像show/hide那样只添加显示内联。