javascript - jquery not working in my code -
i tried using jquery on website, did not seem work. code doesn't work. when click on #test, doesn't hide. please help. thanks!
this html file :
<!doctype html> <html> <head></head> <body> <p id="#test">hello world !</p> <script src="js/jquery.js"></script> <script type="text/javascript" src="js/code.js"></script> </body> </html>
this code.js :
$(document).ready(function() { $('#test').click(function() { $('#test').hide(); }); });
your html wrong, remove hash #
sign:
<p id="test">hello world !</p> // right
while have written:
<p id="#test">hello world !</p> // wrong
note:
you can current element reference using this
:
$(document).ready(function() { $('#test').click(function() { $(this).hide(); }); });
$("#test")
means select element has id equal test
Comments
Post a Comment