[Jquery tutorial] jquery HTML operations

Source: Internet
Author: User
Change HTML content syntax
$(selector).html(content)

The HTML () function changes the content of the matched HTML element (innerhtml ).

Instance
$("p").html("W3School");
Add HTML content syntax
 
 
$(selector).append(content)

The append () function appends content to the matched HTML element.

Syntax
$(selector).prepend(content)

The prepend () function provides the prepend content to the matched HTML element.

Instance
$("p").append(" W3School");
Syntax
$(selector).after(content)

The After () function inserts HTML content after all matching elements.

Syntax
$(selector).before(content)

The before () function inserts HTML content before all matching elements.

Instance
$("p").after(" W3School.");
Jquery document Operation Method

These methods are applicable to both XML and HTML documents except HTML ().

Method Description
Addclass () Add the specified class name to the matched element.
After () Insert content after matching elements.
Append () Append content to the matching element.
Appendto () Append content to the matching element.
ATTR () Sets or returns the attributes and values of matching elements.
Before () Insert content before each matching element.
Clone () Create a copy of the Matching Element Set.
Detach () Removes a set of matching elements from the Dom.
Empty () Delete all child nodes in the matched element set.
Hasclass () Check whether the matched element has the specified class.
HTML () Sets or returns the HTML content of the matched element set.
Insertafter () Insert matched elements to the end of another specified Element Set.
Insertbefore () Insert the matched element to the front of another specified Element Set.
Prepend () Forward content to each matching element.
Prependto () Forward content to each matching element.
Remove () Remove all matched elements.
Removeattr () Removes the specified attribute from all matched elements.
Removeclass () Deletes all or specified classes from all matching elements.
Replaceall () Replace all matched elements with matched elements.
Replacewith () Replace the matched element with the new content.
Text () Sets or returns the content of the matching element.
Toggleclass () Adds or deletes a class from a matched element.
Unwrap () Removes and replaces the parent element of the specified element.
Val () Sets or returns the value of the matching element.
Wrap () Enclose matched elements with specified content or elements.
Wrapall () Enclose all matching elements with specified content or elements.
Wrapinner () Enclose the child content of each matching element with the specified content or element.

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.