- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change text inside an element using jQuery?
To change text inside an element using jQuery, use the text() method.
Example
You can try to run the following code to replace text inside an element:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('#demo').text('The replaced text.'); }); </script> </head> <body> <div id="demo"> <p>The initial text</p> </div> </body> </html>
- Related Articles
- Disable text wrapping inside an element using CSS
- How to replace only text inside a div using jQuery?
- How to change the element id using jQuery?
- Select and Deselect Text Inside an Element using JavaScript
- How to append an element before an element using jQuery?
- How to append an element after an element using jQuery?
- How to clone an element using jQuery?
- How to prepend content to the inside of every matched element using jQuery?
- How to change the text color of an element in HTML?
- How to remove an element from DOM using jQuery?
- How to insert an element into DOM using jQuery?
- How to change the value of an attribute using jQuery?
- How to change CSS using jQuery?
- How to change the src attribute of an img element in JavaScript / jQuery?
- How to get the width of an element using jQuery?

Advertisements