有没有一种更简单、更短的方法来编写一种显示和隐藏 div 的方法,而不必将每一行都表示为显示或隐藏?
function startOver() {
$('.box1').hide();
$('.box2').hide();
$('#box3').hide();
$('.box4').show();
$('.box5').show();
$('.box6').show();
$('.box7').show();
$(".aboveDiv").html("Insert Text");
}
最佳答案
尝试 multiple-selector使用 jquery 的 ,
function startOver() {
$('.box1, .box2, #box3').hide();
$('.box4, .box5, .box6, .box7').show();
$(".aboveDiv").html("Insert Text");
}
关于javascript - 编写隐藏/显示 div 代码的更短、更简单的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35155121/