How to show/hide DIVs with jQuery

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

    DEMO

    function showPage(showdiv){
        $(showdiv).show().siblings().hide();
    }
    

    Or, without using IDs:

    DEMO

    $('ul a').click(function() {
        var index = $(this).index();
        $('#midRight > div').hide().eq(index).show();
    });
    

提交回复
热议问题