Javascript相当于Jquery的隐藏和显示

这个问题在这里已经有了答案:

  • JavaScript隐藏/显示元素10个答案

  • 这很简单

    document.getElementById('myElement').style.display = 'block'; // show
    document.getElementById('myElement').style.display = 'none'; // hide
    

    在你的选择中添加一个onSelect="selectOptionsupdated(this)

    然后

    function selectOptionsupdated(select){
    //do your stuff here  
    }
    

    var myButton = document.getElementById('myButton');
    
    //hide
    myButton.style.display = 'none';
    
    //show
    myButton.style.display = 'block';
    

    更新你选择的标签..这个

    HTML

    <select id="list">
    <option id="1">Science</option>
    </select>
    

    JS

    var list = document.getElementById('select');
    
    list.addEventListener('change', listSelect, false);
    
    function listSelect(){    
        var selected = list.options[list.selectedIndex].value;//Selected option value    //hide
        myButton.style.display = 'none';
    
        //show
        myButton.style.display = 'block'; 
    }
    

    document.getElementById("button").style.visibility="visible|hidden|collapse|inherit";
    
    链接地址: http://www.djcxy.com/p/83559.html

    上一篇: Javascript equivalent of Jquery hide and show

    下一篇: Hide CSS Element Without Changing Display Property