Illep Illep - 4 months ago 17
HTML Question

Hide HTML link button on page load

I want to hide the button

onLoad
. How can I do so. My code is as follows and it doesn't hide the button when the page loads.

HTML

<a class='btn btn-primary' id="button1">my buttopn</a>


JQUERY

<script type="text/javascript">

//
$("#button1").hide();

</script>

Answer

You need to add $(document).ready for load.

 $(document).ready(function(){
    $("#button1").hide();

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" id="button1">Button1</a>
<a href="#" id="button2">Button2</a>

Comments