How does jQuery get content
Editor to share with you how to get the content of jQuery, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Get the content-text (), html (), and val ()
Three simple and practical jQuery methods for DOM operations:
Text ()-sets or returns the text content of the selected element
Html ()-sets or returns the contents of the selected element (including the HTML tag)
Val ()-sets or returns the value of the form field
The following example shows how to get content through the jQuery text () and html () methods:
Example
$("# btn1") .click (function () {
Alert ("Text:" + $("# test") .text ())
});
$("# btn2") .click (function () {
Alert ("HTML:" + $("# test") .html ())
});
The following example shows how to get the value of an input field through the jQuery val () method:
Example
$("# btn1") .click (function () {
Alert ("Value:" + $("# test") .val ())
});
The above is all the content of the article "how to get the content of jQuery". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!