How to replace href links in text using jQuery


Alpha reticulum cells

HTML example:

<p><a href='link1' target='_blank'><font color='blue' size='4'>TEXT 1</font></a></p> <br />      
<p><a href='link2' target='_blank'><font color='blue' size='4'>TEXT 2</font></a></p> <br />      
<p><a href='link3' target='_blank'><font color='blue' size='4'>TEXT 3</font></a></p> <br />

When onclick of TEXT 1, TEXT 2, TEXT 3 then I want to replace link1using linkother1, link2with linkother2, link3with linkother3.

How to do this in jQuery JavaScript? (sorry for my bad english)

solution:

Thanks Johnny-Y,

$('a[href="link1"]').attr("href", "linkother1")
$('a[href="link2"]').attr("href", "linkother2")
$('a[href="link3"]').attr("href", "linkother3")
Johnny

Of course you can my friend :)

$('a[href="link1"]').attr("href", "linkotherone")

everything is possible with jquery :)

Duplicate: change hyperlin

Related


How to replace href links in text using jQuery

Alpha reticulum cells HTML example: <p><a href='link1' target='_blank'><font color='blue' size='4'>TEXT 1</font></a></p> <br /> <p><a href='link2' target='_blank'><font color='blue' size='4'>TEXT 2</font></a></p> <br /> <p><a href='link3' target='_

How to replace href links in Textarea with jQuery

radical action I have a basic question about jQuery. I really want to change the "a" tag in Textarea. I know "a" tags don't work inside a textarea, so I can't use jQuery selectors to target them. example: <textarea><a href="http://www.google.com"></a></textare

How to replace href links in Textarea with jQuery

radical action I have a basic question about jQuery. I really want to change the "a" tag in Textarea. I know "a" tags don't work inside a textarea, so I can't use jQuery selectors to target them. example: <textarea><a href="http://www.google.com"></a></textare

How to find and replace text URLs with links in jQuery

Ajay Hi I want to find text url in editor and convert it to anchor tag link using jquery. this is my code function urlify(text) { var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/; return text.replace(urlRegex, fun

How to find and replace text URLs with links in jQuery

Ajay Hi I want to find text url in editor and convert it to anchor tag link using jquery. this is my code function urlify(text) { var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/; return text.replace(urlRegex, fun

How to find and replace text URLs with links in jQuery

Ajay Hi I want to find text url in editor and convert it to anchor tag link using jquery. this is my code function urlify(text) { var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/; return text.replace(urlRegex, fun

How to find and replace text URLs with links in jQuery

Ajay Hi I want to find text url in editor and convert it to anchor tag link using jquery. this is my code function urlify(text) { var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/; return text.replace(urlRegex, fun

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to find and replace href values on links using AngleSharp?

Rays I have some HTML snippets that contain some links with hrefs that start with a pound sign like this <a href="#Getting Started">Getting Started</a> I'm new to AngleSharp and am trying to use it to find these links and replace the href with the new value,

How to extract all links (href + text) from a page using Scrapy

Eduardo Daltro I need to extract all the links on the page and from each link I need to get hrefits respective text. If any page has a total of 3 links: <a href="https://www.stackoverflow.com">This is the Stackoverflow page</a> <a href="https://example.com">Th

How to replace some text in href of anchor tag in jQuery

Ram Singh I have few url anchors like "http%3a/test.dev.test.com/posts/test test" and I want to replace it with " http://test.dev.test.com/posts/test Test" on the window loading function, I have tried the following code but it does not update the url of the an

How to replace some text in href of anchor tag in jQuery

Ram Singh I have few url anchors like "http%3a/test.dev.test.com/posts/test test" and I want to replace it with " http://test.dev.test.com/posts/test Test" on the window loading function, I have tried the following code but it does not update the url of the an

How to replace some text in href of anchor tag in jQuery

Ram Singh I have few url anchors like "http%3a/test.dev.test.com/posts/test test" and I want to replace it with " http://test.dev.test.com/posts/test Test" on the window loading function, I have tried the following code, but it doesn't update the anchor tag's

How to replace some text in href of anchor tag in jQuery

Ram Singh I have few url anchors like "http%3a/test.dev.test.com/posts/test test" and I want to replace it with " http://test.dev.test.com/posts/test Test" on the window loading function, I have tried the following code, but it doesn't update the anchor tag's

jQuery - Simple text spinner with href links

username I'm using the "Simple Text Rotator" and its awesome functionality, the only problem I'm having is that the text I'm trying to rotate is a link: <h1 class="sliding-text"> <span class="rotate"> <a href="#link-1">Link 1</a>, <a href=

jQuery - Simple text spinner with href links

username I'm using the "Simple Text Rotator" and its awesome functionality, the only problem I'm having is that the text I'm trying to rotate is a link: <h1 class="sliding-text"> <span class="rotate"> <a href="#link-1">Link 1</a>, <a href=

How to replace links in proper href tags

Monney I have six hreftabs body. I selected all links and modified all of them. Now I want to use the modified link instead. My question is how to replace the link hrefin the exact tag var links = document.getElementsByTagName('a'); var new_str=[]; var new

How to replace links in proper href tags

Monney I have six hreftabs body. I selected all links and modified all of them. Now I want to use the modified link instead. My question is how to replace the link hrefin the exact tag var links = document.getElementsByTagName('a'); var new_str=[]; var new

How to replace links in proper href tags

Monney I have six hreftabs body. I selected all links and modified all of them. Now I want to use the modified link instead. My question is how to replace the link hrefin the exact tag var links = document.getElementsByTagName('a'); var new_str=[]; var new

How to replace links in proper href tags

Monney I have six hreftabs body. I selected all links and modified all of them. Now I want to use the modified link instead. My question is how to replace the link hrefin the exact tag var links = document.getElementsByTagName('a'); var new_str=[]; var new

How to replace text groups in links

ain sama I have a Regex that detects a certain type of link. The detection part is working but the replace part is not working, I tried to replace on http://regex101.com/ Code: $link="cover_photos_s/yasinallana1984751717_post_notif_aurora_kuenzli_big.jpg"; //

How to replace text groups in links

ain sama I have a Regex that detects a certain type of link. The detection part is working but the replace part is not working, I tried to replace on http://regex101.com/ Code: $link="cover_photos_s/yasinallana1984751717_post_notif_aurora_kuenzli_big.jpg"; //

why href links are not added to html using jquery

xiaqian1999 I create variables for event links and when the user enters the link I want it to be displayed as a hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_li