WEB Front-end -- JavaScript, WEB -- JavaScript

Source: Internet
Author: User

WEB Front-end -- JavaScript, WEB -- JavaScript

1. If HTML is a structure and CSS is a manifestation, JavaScript is a behavior that can really make pages move.
2. I learned about JS in two ways. We need to understand that JS is used to respond to user operations. User operations are similar to two aspects.
① Open the page and load the page.
② Perform operations on objects on the page, usually by clicking.
Let's talk about the js Code and page loading issues.
① Where should I write js Code? For specific content, I can summarize the blog on programming issues.
② Page loading is also the same as above.

To continue with the above problem, when you click an object on the page, we need to get this object before we can operate on it. Specifically, there are three methods.
1.doc ument. getElementById (); the most common method.
2.doc ument. getElementsByTagName (); get the object through the tag name.
3.doc ument. getElementsByName (); get the object through its name attribute.

We need to use this object to operate other objects.
Here we need to have a tree concept. Let's look at a figure:

The object we mentioned here is the DOM object.
DOM: Document Object Model, Document Object Model. Simply put, all the elements you see on the page are DOM objects.

In addition, we obtained the DOM object through three methods above. Through this object, we can obtain all the element nodes of its parent and child, brother, ancestor, and descendant. In this way, all objects on the entire page can be obtained.

The next step is to perform operations on these objects, such as getting properties, getting text content, setting property values, setting content in the text, creating, deleting, and inserting objects around the object.

We can do whatever we want on all the elements of the page, and the page will be moved (dynamic, not dynamic ).

After talking so much about a language, you must first learn its syntax. But before learning its syntax, you must first have an understanding of the language. JavaScript is a weak language. You need to know where it is weak and then start learning. At the same time, we need to understand a rule. The syntax of a language is similar to the definition of variables, usage of methods, operators, process control, and annotations.

JS:
Variable declaration:
Var a = 1;
Var B = "123"; // it reflects the weak JS language. Think about Java. Can you write it like this? This is one of the manifestations of the strong type of Java language.
Function declaration:
Function fun (){

}
Var a = function (){

} // The function is also an object

Object creation:
Var obj = new Object ();
Var obj = {};
-> JSON object:
-> Var jsonObj = {"key1": "value1", "key2": "value2 "};

Note: It is the same as a Java single-line multi-line comment.

Event. For example, The onclick event

As if it was done, it was just a start. When I started learning, I had to find w3cschool if I had no problems, of course, some special effects still require logical thinking. But we don't need to pay too much attention to JS. We will learn about jQuery in the future. There are many things encapsulated in it, so we can use it directly. OK. Over, go to bed.

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.