Javascript equivalent of Jquery hide and show

This question already has an answer here:

  • JavaScript hide/show element 10 answers

  • this is simple

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

    add a onSelect="selectOptionsupdated(this) in your select

    then

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

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

    Update for your select tag..try this

    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/83560.html

    上一篇: 通过单击另一个类来切换类的可见性

    下一篇: Javascript相当于Jquery的隐藏和显示