A sample analysis of the relationship between JS, Dom, and jquery _ Basics

Source: Internet
Author: User
Tags object model
DOM (Document Object model) is actually a generic term for element objects within a browser

All of the things we do with JavaScript in a Web page are done through the DOM. The DOM belongs to the browser, not the core of the rules in the JavaScript language specification, so if you download a JavaScript language reference help document to look up, even including women's document.write method is not found.

The Document Object Model (MODEL,DOM) is a programming interface for HTML and XML documents. It provides a structured representation of documents that can change the content and presentation of documents. What we are most concerned about is that Dom links Web pages with scripts and other programming languages. Script developers can control, manipulate, and create dynamic Web page elements through the properties, methods, and events of document objects. Each page element (an HTML tag) corresponds to an object (object, the so-called "objects"), in the words "things" in white. The Word object is usually translated into "objects" in Taiwan. The labels on the Web page are nested, the outermost layer is <HTML&GT, and the Document Object model is nested like this, but is usually understood as a tree shape. The root is the window or Document object, which is the outer edge of the outermost label, the entire document.

As a small example:
Copy Code code as follows:

<script type= "Text/javascript" >
var x = document.getElementById ("test");
var xc = X.childnodes;
var xcl = xc.length;
for (Var i=0;i<xcl;i++) {
document.write ("nodename =" + Xc[i].nodename +); NodeType = "+ Xc[i].nodetype + <br/>");}
</script>

JavaScript can operate on the DOM, such as: A <table> is a DOM object that JavaScript could add, delete, and so on.

Many people see Java and JavaScript have "Java" four words, think they are the same thing, even I was the same. In fact, they are two completely different kinds of things. Java, the full name should be Java applet, is embedded in the Web page, but also has its own independent run window applet. Java applets are precompiled, and an applet file (. Class) opens reading in Notepad, which is simply incomprehensible. Java applets are powerful, with access to protocols such as HTTP, FTP, and even viruses on the computer (there is a precedent). In contrast, JavaScript is less capable. JavaScript is a "script" that writes code directly into an HTML document that the browser compiles and executes when it reads them, so you can view the JavaScript source code by viewing the HTML source file. JavaScript does not have a separate running window, and the browser's current window is its running window. The similarities, I think, are just the same as programming languages in Java. JavaScript is a client-side scripting language that is based on object and event-driven and has relative security. It is also a kind of scripting language widely used in client Web development, which is often used to add dynamic functions to HTML Web pages, such as responding to user's various operations.

As a small example:
Copy Code code as follows:

var myvariable= "Outside";
function MyFunction () {
var myvariable= "Inside";
alert (myvariable);
}
MyFunction ();
alert (myvariable);

jquery is the so-called JavaScript framework, which is actually a collection of javacript functions, packaged.

jquery is an excellent JAVASCRĪPT framework after prototype. It is a lightweight JS library (only 21k after compression), it is compatible with CSS3, but also compatible with a variety of browsers (IE 6.0+, ff1.5+, Safari 2.0+, Opera 9.0+). jquery makes it easier for users to handle HTML documents, events, animations, and easily provide Ajax interaction for the site. One of the big advantages of jquery is that it has a full documentation and a variety of applications that are detailed, as well as a number of mature plug-ins to choose from. jquery enables the user's HTML page to keep the code and HTML content separate, that is, you don't have to insert a bunch of JS into the HTML to invoke the command, just define the ID.

jquery is currently the most widely used JavaScript library of functions. According to statistics, the world's top 1 million websites, 46% use jquery, far more than other libraries. Microsoft even took jquery as their official repository. It is necessary for web developers to learn jquery. Because it gives you an idea of the industry's most versatile technology, lays the groundwork for a more advanced library in the future, and it does make a lot of complex effects easy.

As a small example:
Copy Code code as follows:

<script type= "Text/javascript" src= "Jquery.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("P"). Click (function () {
$ ( This). Hide ();
});
});
</script>

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.