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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -