Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  89] [ 6]  / answers: 1 / hits: 16744  / 13 Years ago, mon, august 29, 2011, 12:00:00

Here is the code I have:



      $('#link').attr(href,link) 
$('#link').text(text)


How do I change the title of a link using jQuery? I'm correctly changing the url, but I can't edit the text, what am I doing wrong?



<a id=link href= target=_blank>text</a>



$('#link').attr(href,data[1].url)
$('#link').attr(title,data[1].title)

<a href=http://link.com>title</a>


I'm tring to simply change 2 things:




  1. url

  2. title (as show above)



I'm able to change the link, but the title won't change. I'm selecting the wrong trhing. Therefor is there a way to list all attr available to me? Or are you able to help me change the text title above?



Either answer is acceptable.



        <div id=highlight class=topicHighlight hero1>
<h3 id=h3>hero_1_large_text</h3>
<p id=p></p>
<span id=coverTextSpan>hero_1_small_text</span>
<a id=link href=url target=_blank>text</a>
</div>

More From » jquery

 Answers
16

use html function:



$('#link').html(text);


or , if you are talking about the title attribute:



$('#link').attr('title','some title');

[#90375] Friday, August 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lesterluiss

Total Points: 513
Total Questions: 104
Total Answers: 106

Location: Honduras
Member since Sat, Jul 24, 2021
3 Years ago
;