How to show/hide DIVs with jQuery

前端 未结 4 1104
难免孤独
难免孤独 2021-01-17 04:28

I want to make a function to show and hide a div tag and hide all others:

function showPage(showdiv){
    $(\'#midRight\').not(showdiv).hide(); 
    $(showdi         


        
4条回答
  •  生来不讨喜
    2021-01-17 04:58

    You could write you selector to hide all child div's of midRight, then show the div with the passed ID. No need to cast to a String, since that is what you are passing:

    function showPage(showdiv){
        $('#midRight > div').hide()  
        $(showdiv).show();    
    }
    

提交回复
热议问题