Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:03:16+00:00 2026-05-23T17:03:16+00:00

var href = $(‘a[target=_blank]’).attr(‘href’); $(‘a[target=_blank]’).attr(‘title’, ‘Öppnas i en ny flik; ‘ + href); Let’s

  • 0

var href = $(‘a[target=”_blank”]’).attr(‘href’);
$(‘a[target=”_blank”]’).attr(‘title’, ‘Öppnas i en ny flik; ‘ + href);

Let’s say I have a link in the header.php file with target="_blank". In the donate.php file I have another link with target="_blank". The code I show you above does only take the href value from the link in the header.php file. How do I take the href value in every link I have on the current page?

If I have the mouse cursor over the link in header.php, it will show “Öppnas i en ny flik; http://the-link.nu/“. If I have the mouse cursor over the link in donate.php, it will show “Öppnas i en ny flik; http://another-link.nu/“.

Any help to fix this problem? 🙂
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:03:17+00:00Added an answer on May 23, 2026 at 5:03 pm
    $('a[target="_blank"]').each(function() {
        $(this).attr('title', 'Öppnas i en ny flik; ' + $(this).attr('href'));
    });
    

    You’re only getting the first anchor’s attribute because $.attr() is designed to get just the value from the first matched element. Using $.each lets you loop through all of the elements found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have this: $('a').each(function() { $(this).click(function(e) { e.preventDefault(); var href = $(this).attr('href');
I have this var in my code: var href = $(this).attr('href'), str = href.split('/').slice(-2,-1)[0];
I have below code written in jQuery: var href = window.location.href; if (href.search('/welcome\\/') >
Imagine the following markup: <a href=#link01>1</a> <a href=#link02>2</a> And: $('a').click(function(){ var href = $(location).attr('href'),
<link rel=EditURI type=application/rsd+xml title=RSD href=http://www.blogger.com/rsd.g?blogID=7487871339000666216 /> How can I get the href attribute of
I have some code like below $(html).on(change, input['data-href'], function() { var href, obj, params;
The response is a HTML document (from a request from a link's href) var
$(function(){ $('a').each(function(){ var x=this.href; this.href=www.somesitename.com/filter+this.href; }); }); i wrote the above jQuery script to
var tagMatch; if (tagMatch = window.location.href.match(/\/questions\/ask\?tags=([^&]+)/)) { $(function() { if (!$('#tagnames').val().length) { $('#tagnames').val(unescape(match[1].replace(/\+/g, '
This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.