adspace
What is the difference between text() and html() in jquery?
Answer Posted / Shyam Babu
Both `text()` and `html()` are used to get or set content within an element, but they differ in how they handle HTML tags. When you use `text()`, it removes any HTML tags within the selected elements and only returns the text content. If you want to set text content while preserving HTML tags, use `html()`. Conversely, when you use `html()` to get content, it returns the complete HTML markup of the matched elements, including their children and any HTML tags.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to validate email using jquery?
How can jquery library be added to pages?
How to always reference latest version of jquery?
How do you install/use jquery in a project. What is the minimum setup needed to start using jquery.
Do you have plans for a new jquery plug-in or something else we should look out for? Where to from here for the imgpreview plugin?
What is the minimum setup needed to start using jquery.