Home > Web Front-end > JS Tutorial > body text

jquery learning part 2 attributes (html() and html(val))_jquery

WBOY
Release: 2016-05-16 18:15:32
Original
1073 people have browsed it
html()
Get the html content of the first matching element. This function cannot be used with XML documents. But it can be used for XHTML documents.
Get the html contents of the first matched element. This property is not available on XML documents (although it will work for XHTML documents).
Return value
String

Example
Copy code The code is as follows:

HTML code:

< p>Hello


jQuery code:

$("div").html();

Result:

Hello

html(val)
Set the html content of each matching element. This function cannot be used with XML documents. But it can be used for XHTML documents.
Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents).
Return value
jQuery

Parameters
val (String): Value used to set HTML content

Example
Copy code The code is as follows:

HTML code:

jQuery code:
$("div").html("

Hello Again


Result:
[

Hello Again

]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!