I have the following html generated by a CMS for a tabbed element:
<li class="active" style="width: 233px;">
<a href="#tabopen_tickets">Open Tickets</a>
</li>
I want to change the link's
text of "Open Tickets" to other text, but I only know the link's href
.
How can I do this with jQuery? Thanks!
I have the following html generated by a CMS for a tabbed element:
<li class="active" style="width: 233px;">
<a href="#tabopen_tickets">Open Tickets</a>
</li>
I want to change the link's
text of "Open Tickets" to other text, but I only know the link's href
.
How can I do this with jQuery? Thanks!
Share Improve this question edited Jun 30, 2014 at 14:06 Pratik Joshi 11.7k7 gold badges44 silver badges73 bronze badges asked Jun 27, 2014 at 7:08 TheRealPapaTheRealPapa 4,5399 gold badges80 silver badges165 bronze badges 1- Try serverfault. (system administrators) or superuser. for your desktop machine problem from your deleted post. – Stein Åsmul Commented Jun 29, 2014 at 7:11
4 Answers
Reset to default 4$('a[href="#tabopen_tickets"]').html('your new value');
Try
Attribute Equals Selector [name="value"]
$('a[href="#tabopen_tickets"]').text('Changed');
$('a[href="#tabopen_tickets"]')
will select the a
tag with href
attribute #tabopen_tickets"
You can use:
$('li.active a').text("new text here");
if you want to get it by href then use attribute equal selector:
$(a[href="#tabopen_tickets"]).text("new text here");
You can select link with jquery that contains, start or end with some text like this
var link = $('a[href*="#tabopen_tickets"]')
and
then change the link text like link.innerHTML("new text");
Documentation can be found here