[Answered ]-Why does the js function need to be inside the html file and cannot be separates in this case?

2👍

Things need to be taken care:-

1.Add a jquery library before any jQquery code (otherwise jQuery code will not executed).

2.Either put your script code at the end of the page or change it like below :-

$(document).ready(function(){
   $(".pure-toggle-label").click(function () {
       console.log("Hello World");
   });
});

0👍

Js code (and jquery in your case ) will be executed as soon as the js interpreter find the snippets to execute… if the code to be executed is invoked before any js lib is loaded then you will get an “… not found error”… on the other hand most of initializing functions are anchored to the onload method in the site, this is because most jquery functions are related with dom elements that must be properly loaded before getting manipulated

Leave a comment