Javascript equivalent of Jquery hide and show -
this question has answer here:
- javascript hide/show element 9 answers
i have simple hide , show jquery code , want ask if there equivalent of javascript? here's code.
jquery:
$(document).ready(function(){ $("#mybutton").hide(); $("#1").click(function(){ $("#mybutton").show(); $("#mybutton").click(function(){ $("#mybutton").hide(); }); }); }); html:
<select> <option id="1">science</option> </select> <input type="button" value="click" id="mybutton"/> i followed codes in comments below not working:
javascript:
<script> document.getelementbyid('mybutton').style.display = 'none'; function selectoptionsupdated(select){ document.getelementbyid('mybutton').style.display = 'block'; } </script> html:
<select onselect="selectoptionsupdated(this)"> <option id="1">science</option> </select> <input type="button" value="click" id="mybutton"/> what want @ first button hidden, , when click <option> tag "science" button appears , when click button, button hidden after being clicked. , if there more <option> tags? sorry i'm still beginner. appreciated.
this simple
document.getelementbyid('myelement').style.display = 'block'; // show document.getelementbyid('myelement').style.display = 'none'; // hide add onselect="selectoptionsupdated(this) in select
then
function selectoptionsupdated(select){ //do stuff here }
Comments
Post a Comment