jQuery > Attribute related method

.text() - Get set text of element in jQuery

How to get or set the text of element in jQuery?

To get or set the element text content (including the child elements), text() method can be used.


Above code snippet will set the text content of element “div2” as the html content to the element “div3”.

      $("#div3").text("This text is set by <b>jQuery</b> !");

Above code snippet will set specified text to the element whose id is “div3”.

 Views: 4384 | Post Order: 34

Write for us

Hosting Recommendations