How to display one div and hide all others

前端 未结 7 1157
温柔的废话
温柔的废话 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:41

    Add a class to all the divs u want to show or hide eg:

    <div id=a class="hide" style="display:none">1</diV>
    

    And then add the following statement to each onclick function

     $('.hide').css('display','none'); /* Replace .hide with whatever class name u have chosen*/
    

    To see the answer in action: http://jsfiddle.net/6UcDR/1/

    0 讨论(0)
提交回复
热议问题