Javascript File Works For One Html File But Not The Other
I have a JS file linked to my index.HTML file that works fine but it will not work for other .HTML file. Why is this. They elements I needs Javascript to apply to are the same and
Solution 1:
Please check this you have to write like this,
In the HTML file, you have to add one attribute id/class
 <form action="#"id="formData">
 </form>
In jquery/javascript "use anyone it's up to you"
//javascript var form = document.getElementById('formData');
//jqueryvar form = $("#formData");
/*add your script code like this*/
form.addEventListener("submit", handleSubmit)
  $(window).scroll(function () {
    if (this.scrollY > 20) {
      $(".navbar").addClass("sticky");
      $(".goTop").fadeIn();
    } else { 
      $(".navbar").removeClass("sticky");
      $(".goTop").fadeOut();
    }
  });
Solution 2:
try deleted id="cNavbar-menu" in the unworked html
Post a Comment for "Javascript File Works For One Html File But Not The Other"