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

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -