How to show/hide DIVs with jQuery

前端 未结 4 1106
难免孤独
难免孤独 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:43

    Fixed up some syntax errors. As the comments say, you're appending an empty string with the variable, just use the variable. Also, you need to tell the selector to select the children of the targetted container:

    function showPage(showdiv){
        $('#midRight').children().not(showdiv).hide();  
        $(showdiv).show();  
    }
    

    Demo: http://jsfiddle.net/ACGMj/1/

提交回复
热议问题