JavaScript and JQuery Accessing HTML Elements -


i have html file in import jquery own javascript file. when put:

<script> $( "#htmlid" ).click(function() {   $( "#htmlid" ).hide(); }); </script> 

in html file , click on "htmlid" div in question, hides it. however, when put:

$( "#htmlid" ).click(function() {   $( "#htmlid" ).hide(); }); 

in javascript file, doesn't work. why this?

try wrap following:

$(document).ready(function(){     $( "#htmlid" ).click(function() {       $( "#htmlid" ).hide();     }); }); 

Comments

Popular posts from this blog

minify - Minimizing css files -

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -