jQuery – Set Content

To set the content on a web page using jQuery, we can use the text(), html() and val() methods. In this lesson, we will learn how to,

  • Set the Text of the selected element
  • Set the Content of the Form Fields

Set the Text of the selected element

To set the text of the selected element in jQuery, use the text() and html() methods. Let us see an example wherein we will set the text of the <p> element:

jQuery Set the Text of the selected element

Set the Content of the Form Fields

To set the content of the Form fields, use the val() method in jQuery. Let us see another example wherein we will set the content to 3 form fields:

Output

jQuery Set Content of the Form Fields

jQuery - Get Content
jQuery - Add Element
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading