O (∩_∩) o~~ is a new week to start, today still continue to learn JavaScript knowledge, today is mainly about the knowledge of the event. Let's summarize it now.Eventevents are typically used for browser and user actions to interact. First appeared
Set the timer to execute the specified code after a period of time, the difference between setTimeout and setinterval is that the code specified by the SetTimeout function executes only once method one: Window.settimeout ("alert (' OK ')", 5000 );
1. The suffix of each user script must be. User. JS, for example, helloworld. User. js. Its content is as follows:
// ==UserScript==// @name Hello World// @namespace http://diveintogreasemonkey.org/download/// @description example
Set the timer and run the Specified Code after a period of time. The difference between setTimeout and setinterval is that the Code specified by the setTimeout function is only executed once.
Method 1:
Window. setTimeout ("alert ('OK')", 5000
Window. onload:
You must wait until all content on the webpage is loaded;
You cannot concatenate multiple functions at the same time.Code:
Window. onload = function (){Alert ("Hello, world 0! ");};
Window. onload = function (){Alert
Javascript has a lot of interesting usage, which can be found in GoogleCodeSearch. Today, I have seen it from the huoding notes, which is very good. I suggest you read it. For example:
Script ~ Function () {alert ("hello, world.") ;}(); script
First, maintainability: understandable, intuitive, adaptable, scalable, and can be debugged
Code Conventions:
Readability
Formatting: Recommended indent size is 4 spaces
Comments: Functions and methods,
"Add event mechanism" AddEventListener and attachevent[The]AddEventListener (' click ', function () {alert (' Hello World ')}, FALSE)//W3C specification add event (IE8 and above incompatible); The first argument is the event type, the second is the
Intermittent callIntermittent calls are common in JavaScript, setinterval, which is repeated calls over a certain amount of time.The SetInterval () method receives two parameters: the first argument can be a string or a function, and the second
Do and loop structuredo{Circulation body;}while (cyclic conditions);Show "Hello World" five timesvar I=1;while (I{Alert ("Hello World")i++;}var j=6;do{Alert ("Hello World")j + +;}while (jThe loop body is executed at least once, and the while loop
1) Control scopeThe query for the symbol of the variable always follows the scope chain, starts the query from the local scope, stops if it is found, or continues querying the outer scope .... Until the global scope is reached.So: Access time for
"Add event mechanism" AddEventListener and attachevent
[The consortium]
AddEventListener (' click ', function () {alert (' Hello World ')}, FALSE)//W3C specification add event (IE8 and above incompatible); The first parameter is the event type,
Here are the various types of JS functions I have seen and the invocation, although some of the wording and its invocation I do not know what the jargon is called, but does not affect me to write a summary note.We are just beginning to touch the JS
Now there are more and more friends who use jquery, but there are also various jquery selectors. Let's test common jQuery selectors for you. If you need to know about them, please refer to them.
You can flexibly test JS code snippets on the page.
#事件流 Event capture: Capture of elements triggered by document to event Event bubbling: triggered by the element triggering the event to the superior #事件处理程序 HTML Event handlers type= "button" value= "pushbutton" onclick= "alert (' Hello World ') "
plug-in understanding. $.extend () and $.fn.extend ()Plug-in development includes two kinds: 1. The class-level plug-in development, i.e. $.extend () extends the jquery object itself; 2. The object-level plug-in development, or $.fn.extend ()
JQuery selectors are everywhere. Do you know their performance ?, Jquery Selector
Nowadays, jQuery is becoming more and more popular on the website. Therefore, even a little bit of understanding, advantages, and shortcomings of jQuery are more and
First, let's assume that we need a say method to use one sentence, and a walk method to represent taking a step. Then let's implement the definition of the two methods in five ways.
1. Function say ()
{
Alert ("Hello World ");
}
Recently, I have made some small experiments on jQuery selector usage to demonstrate Which of the following is more efficient and worth using different jQuery selectors under different circumstances.
First, introduce the jquery file provided by
can be flexible on the page of the JS code fragments to test, when used as long as the firejspt of the class library file import can:
Using FIREJSPT, the common selector for jquery was tested under Firefox, and the test environment was as follows:
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.