dimanche 28 novembre 2021

Simple jQuery if else statement

I have a mini script, this script finds within a specific class the link. I basically need a simple if-else-statement. Something like if a is existing, then run the script if not, then do nothing.

Can someone help me with that?

jQuery(document).ready(function() {
  jQuery("body").on("click", ".click-child", function() {
      var href = jQuery(this).find("a").attr('href');
      window.location = href;
  });
});

Aucun commentaire:

Enregistrer un commentaire