Home > Web Front-end > JS Tutorial > body text

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

小云云
Release: 2018-01-01 10:48:54
Original
2295 people have browsed it

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);
  });
});
Copy after login

Related recommendations:

How to solve tag nesting

Understanding html Anchor 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!