Javascript keeps a div hidden until you click a button, need help modifying

前端 未结 2 2029
迷失自我
迷失自我 2021-02-04 07:33

Basically, my code right now keeps a few of the divs I have on my website hidden and then when you click on a link, it makes the divs appear.

I need help so that it so t

2条回答
  •  悲&欢浪女
    2021-02-04 08:33

    I don't understand your question properly. But if you are trying to make different div elements visible upon clicking different links, then this is what you should do:

    
    
    
    

    $(document).ready(function(){
    
            //if you wish to keep both the divs hidden by default then dont forget to hide //them           
            $("#help-content").hide();
            $("#about-content").hide();
    
           $("#about-anchor").click(function(){
                 $("#help-content").hide();
                 $("#about-content").show();
            });
    
          $("#help-anchor").click(function(){
                  $("#help-content").show();
                 $("#about-content").hide();
           });
    });
    

    Also don't forget to add jQuery library.

提交回复
热议问题