How to change a text with jQuery

Viewed 299075

I have an h1 with id of toptitle that is dynamically created, and I am not able to change the HTML. It will have a different title depends on a page. Now when it is Profile, I want to change it to New word with jQuery.

<h1 id="toptitle">Profile</h1> // Changing only when it is Profile  
// to
<h1 id="toptitle">New word</h1>

Note: If the text is Profile, then change it to New word.

8 Answers

*In my case i have stored the new Value in the var altText

$('#toptitle').text(altText);

* And it Worked

Related