Multiple Toggles Almost like Tabs JavaScript/ CSS

前端 未结 2 1995
臣服心动
臣服心动 2021-01-28 12:16

I want to create tabs that function like toggles, but instead only one toggle can be active at one time. The content of the tab also needs to be above the the tabs themselves. T

2条回答
  •  一整个雨季
    2021-01-28 12:35

    This is also tagged jquery so I'll just recommend that you include the jquery library and include:

    $('.someclass').hide();
    

    as the first line in the toggleMeMirror function.

    Then, make sure that each of your looped content divs exist in the class "someclass".

    like:

    foreach($this as $that) {
        print "
    $that
    "; }

    then

    function toggleMeMirror(a){
        // hide all
        $('.someclass').hide();
        //  show one
        var e=document.getElementById(a);
        if(!e) return true;
            if(e.style.display=="none"){
                e.style.display="inline"
            } else {
                e.style.display="none"
            }
        return true;
    }
    

提交回复
热议问题