[jquery method HTML ([VAL|FN])] This method operates on a matching element or content in an element set, equivalent to a innerhtml in JavaScript

Source: Internet
Author: User

Gets the HTML content of the first matching element, which cannot be used in an XML document, but can be used in an XHTML document, and in an HTML document we can use the. html () method to get the contents of any element. If the selector matches more than one element, only the HTML content of the first matching element is fetched, equivalent to the innerHTML in JavaScript, readable and writable, and HTML tags can be parsed

If callback is passed in, this function returns a string and the parameters are resolved as follows:

1.index is the index position of the element in the collection

2.html is the original HTML value.

Instance:

<! DOCTYPE html>Div{font:25px/250px ' Courier New '; Text-align:center;color: #000; border:1px solid #F50; width:700px;height:250px;margin   : 20px Auto;} . addone{padding:08px;} . addtwo{color:#999;}</style><script type= ' Text/javascript ' >    $(function() {alert ($ (' #user '). HTML ()); $(' #user '). HTML (' <strong>this is a test</strong> '); });</script>

[jquery method HTML ([VAL|FN])] This method operates on a matching element or content in an element set, equivalent to innerHTML in JavaScript

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.