-8

i just start to learn jquery so i know nothing. help me to change text and attributes (title)

<li><a href="#" title="LinkedIn">LinkedIn</a></li>

title="LinkedIn"    ==== title="instagram"
LinkedIn    === Instagram

thank you

  • what do you mean by `title`? `title` of document being displayed? if so use `document.title='LinkedIn';` – Vedant Terkar Dec 28 '14 at 14:44
  • Welcome to Stack Overflow. Please take the [tour] and read the [help]. Your question can't be answered in its current state. We ask you to improve it first. – rene Dec 28 '14 at 14:45
  • possible duplicate of [How to change an element's title attribute using jQuery](http://stackoverflow.com/questions/987967/how-to-change-an-elements-title-attribute-using-jquery) – Sidney Gijzen Dec 28 '14 at 14:49

1 Answers1

1

First, give your "a" an id, like so:

<li><a id="myAElement" href="#" title="LinkedIn">LinkedIn</a></li>

Now to change the title, do:

$("#myAElement").attr("title","Instagram");

To change the text displayed, do:

$("#myAElement").html("Instagram");
Pieter De Clercq
  • 1,951
  • 1
  • 17
  • 29