Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to replace innerHTML of a div using jQuery?
To replace innerHTML of a div in jQuery, use the html() or text() method. The html() method sets or returns the HTML content of an element, while text() sets or returns the text content without HTML formatting.
Using the html() Method
The html() method is the jQuery equivalent of JavaScript's innerHTML property. It can both get and set the HTML content of selected elements ?
This is Amit!
Using the text() Method
The text() method replaces content with plain text only, ignoring any HTML tags ?
This is original content!
Conclusion
Use html() when you need to insert HTML content with formatting, and text() when you want to insert plain text content safely without HTML interpretation.
Advertisements
