[Goto] about the difference between HTML (), text (), Val () in jquery

Source: Internet
Author: User

Original address: http://www.cnblogs.com/xiaolifeidao/p/3715830.html

. HTML () corresponds to innerHTML in JS for reading and modifying HTML tags of elements

. HTML () is used to read the HTML content of an element (including its HTML tag), and the. HTML () method reads only the first element when used on multiple elements

. Text () to read or modify the plain text content of the element corresponding to the innertext in JS

Text () is used to read the plain text content of an element, including its descendant elements; The text () method cannot be used on a FORM element

. Val () is used to read or modify the value values of form elements

. Val () is the value that is used to read the form elements,. val () can only be used on form elements

About the difference between the three

1. The Val () method is the same as. html (), and can only read the value of the first FORM element if it is applied on more than one element, but. Text () is not the same as they are, if. Text () is applied on more than one element, the text content of all the selected elements is read.

2. HTML (),. Text (),. Val () can use the return value of the callback function to dynamically change the contents of multiple elements.

[Goto] about the difference between HTML (), text (), Val () in jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.