<script>
$("#btn1").click(function() {
$("#logpop").hide("slow");
});
</script>
<body>
<div id="logpop">
<div class="logpop_box">
<div class="form">
<input class="input_box" name="email" type="text" placeholder="Woosuk"/> <br/><br/>
<input class="input_box" name="pass" type="password" placeholder="******"/> <br/>
<button id="btn1">Login</button>
</div>
</div>
</div>
I want to make div disappear when i click the button. but It dose not disappear. Any thought
Your JavaScript needs to be in a document ready function:
$(document).ready(function() {
$("#btn1").click(function() {
$("#logpop").hide("slow");
});
});
Currently your click handler is executing before the DOM has been created, thus it can't be attached.
You should register your click handler inside a document-ready block:
$(function(){
$("#btn1").click(...);
});
Your script is running before the element exists, and so no click handler is registered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With