Dom operations in jquery

Source: Internet
Author: User

What is DOM?

To change something on a page, JavaScript needs to get access to all the elements in the HTML document. This portal, along with the methods and properties for adding, moving, changing, or removing HTML elements, is obtained through the Document Object Model (DOM).

In 1998, the first edition of the DOM specification was released. This specification allows access to and manipulation of each individual element in an HTML page.

All browsers have implemented this standard, so the DOM compatibility issue is almost impossible to trace. DOM can be used by JavaScript to read, change HTML, XHTML, and XML documents


Html-dom is scripting HTML files using JavaScript and DOM, and there are many attributes that are specifically html-dom. The advent of html-dom is even earlier than Dom core, which provides some more concise notation to describe the attributes of various HTML elements.

Example: Methods for getting Form objects using Html-dom: document.forms


Css-dom is a CSS-specific operation. In JavaScript, the main function of Css-dom technology is to get and set various properties of a style object. By changing the various properties of a style object, you can make the Web page appear in a variety of different effects

To set the font color of an element's style object: = "Red";

Find nodes

Element can read the HTML content in the text () method, which is equivalent to the DOM's innerHTML property

Inserting nodes

For example:

<script src= "Jquery.js" ></script>
$ (function () {
var xj = "<li title= ' banana ' > Banana </li>";
var xg = "<li title= ' watermelon ' > Watermelon </li>";
var ll = "<li title= ' durian ' > Durian </li>";
var bl = "<li title= ' pineapple ' > Pineapple </li>";
var kb = "<li title= ' Kobe Bryant ' > Kobe </li>";
$ ("ul"). Append (XJ); Added in the last
$ (XG). AppendTo ("ul");
$ ("ul"). Prepend (ll); Add again Front
$ (BL). Prependto ("ul");
$ ("ul Li[abc]"). After (KB);
<li title= ' Apple ' > Apple </li>
<li title= ' orange ' abc= ' BC ' > Orange </li>
<li title= ' pineapple ' > Pineapple </li>


Dom operations 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: 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.