dimanche 26 avril 2020

jQuery: Code syntax when comparing text across two separate elements

Can someone kindly tell me what is wrong with the syntax in the block of code below? In case it matters, I am trying to compare the text that displays in two separate elements when a new html page is loaded. When a match is found, I want to display the hidden element to be shown.

Thank you very much.

 function showcategory() {
    var bcrumbtext = $("ol.breadcrumbs").text();
        var catname = $("li.cat").text(); 
            $(catname).each(function() {
      if($(this)===(bcrumbtext)){
            $(this).show();
     }
  )};
}

Aucun commentaire:

Enregistrer un commentaire