Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
11 lines (6 sloc) 691 Bytes

Change Text Inside an Element Using jQuery

Using jQuery, you can change the text between the start and end tags of an element. You can even change HTML markup.

jQuery has a function called .html() that lets you add HTML tags and text within an element. Any content previously within the element will be completely replaced with the content you provide using this function.

Here's how you would rewrite and italicize the text of our heading:

$("h3").html("<i>jQuery Funhouse</i>");

jQuery also has a similar function called .text() that only alters text without adding tags. So when using .html() please remember that you will be editing the whole markup and not just the text.

Something went wrong with that request. Please try again.