About the difference between HTML (), text (), Val () in jquery __html

Source: Internet
Author: User

. HTML () corresponds to the innerHTML in JS for HTML tags that read and modify elements

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

. text () to read or modify elements of plain text content 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 form elements

. val () to read or modify value values for form elements

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

On the difference between three people

. Val () method and. HTML () is the same, and if it is applied on more than one element, only the value of the first FORM element can be read, but. Text () is different from them, and if. Text () is applied to more than one element, the text content of all selected elements will be read.

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

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.