Home  >  Article  >  Web Front-end  >  Detailed explanation of jQuery looping through and changing the href of a tag

Detailed explanation of jQuery looping through and changing the href of a tag

小云云
小云云Original
2018-01-01 10:48:542405browse

This article mainly brings you a jQuery loop to change the href of a tag (explanation with examples). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

Add "#article" to all a tag links under the info category.


jQuery(document).ready(function($){
  $('.info a').each(function(){
    let Ahref = $(this).html() + "#article";
    $(this).attr("href",Ahref);
  });
});

Related recommendations:

How to solve tag nesting

Understanding html 3499910bf9dac5ae3c52d5ede7383485Anchor text A tag

Basic knowledge of mini program css style media tag detailed explanation

The above is the detailed content of Detailed explanation of jQuery looping through and changing the href of a tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn