Hide particular div onload and then show div after click

前端 未结 6 1105
故里飘歌
故里飘歌 2020-12-14 11:31

I have two divs div1 and div2. I want div2 to be automatically hidden but when i click on preview div then div2 to be mad

6条回答
  •  清歌不尽
    2020-12-14 11:48

    You are missing # hash character before id selectors, this should work:

    $(document).ready(function() {
        $("#div2").hide();
    
        $("#preview").click(function() {
          $("#div1").hide();
          $("#div2").show();
        });
    
    });
    

    Learn More about jQuery ID Selectors

提交回复
热议问题