How to display one div and hide all others

前端 未结 7 1181
温柔的废话
温柔的废话 2020-12-11 11:40

I want to display a div on each button click and also want to hide the other all divs how I can do it.

HTML

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 12:33

    Try this jQuery-

    $​('#w').click(function(){
    $('#a').show()
    $('#b,#c,#d').hide()
    });
    
    $('#x').click(function(){
    $('#b').show();
    $('#a,#c,#d').hide()
    });
    
    $('#y').click(function(){
    $('#c').show();
    $('#b,#a,#d').hide()
    });
    
    $('#z').click(function(){
    $('#d').show();
    $('#b,#c,#d').hide()
    });
    

提交回复
热议问题