JS skills you may not know)
1. document. getelementsbytagname can be used to obtain all elements of a tag. getelementsbytagname ('*') obtains all elements on the page. The asterisk represents any tag, and the tagname of the annotation tag is "!"
2. Differences between the string method substr and substringSubstr (start [, length]) indicates that length strings are obtained from the start position.Substring
}; Delete o.x; if ("X" in O) {}//false}7. For infunction Test () { var o={x:1,y:2}; For (i in O) { console.log (o[i]);} }8. Try: Catch.. Finallyfunction Test () { try{ var n=number (Prompt ("Please enter a positive integer")); var f=factorial (n); Alert (n+ "! =" +f); } catch (ex) { alert (ex); } finally{ Aler ("show" whether or not there is an exception); }}function factorial (x) { if (x9. Width statementfunction T
Recently do the front desk, to do a button on the special effects, requirements are pressed down to see is pressed down the feeling. Well, just follow the effect, and the background picture of the two buttons that have already been used in the PS process. Then it should be using CSS and JS to control the effect of it.
Before learning JS has always had a keydown,keyup impression, literally does not seem to
one of the most important best practices in Web performance optimization is reducing HTTP requests. The most important way to reduce HTTP requests is to merge and compress JavaScript and CSS files. When writing CSS, we should pay attention to some details to control the size of the CSS file, such as: Global style, inheritance style, abbreviation style, space, comments, etc., you can also use the online tool to compress your CSS file to reduce the size of the CSS file, but the compressed CSS file
Objective:The function is divided into a parameter with a return value, a parameter has no return value, no parameter has no return value, and no parameter has a return value; So what about the function you want to use without parameters? What if you want to encapsulate a code that implements a variety of functions, but the parameters are larger than the arguments or the arguments are larger than the formal parameters? In this paper, some related operations about parameters, such as value passin
) { longstr+ = ' a ';} // longstr=new Buffer (LONGSTR); Http.createserver (function(req,res) { res.writehead (); Res.end (LONGSTR);});The problem in this case is that every time the request calls Res.end, it is necessary to do an operation equivalent longstr=new Buffer (LONGSTR);So it's time to move this step forward. Remove the comments in the code so that we can store the original longstr directly as buffer, and follow it directly, without wasting the CPU.This article is to read the r
The case address is www. cndf. comorderprice. php. First, I want to know how to calculate the price automatically using several options. By viewing the html, I learned that the {code...} role of this js file, I tested, the source site offline is unable to calculate the results,... case address http://www.cndf.com/order/price.php
First, I want to know how to calc
internet giants, including Facebook, Google and Twitter, have adopted the same technology as meteor in Web applications, the meteor team said. (Project details)
Project home: http://meteor.com
Code Escrow Address: Https://github.com/meteor/meteor
Jqueryjquery is another excellent JavaScript framework following prototype. It makes it easy to manipulate document objects, handle events, animate, use Ajax to interact with websites, and more. Provides APIs that can be used
1, SetTimeoutSetTimeout (function () {}), 1000)SetTimeout (function (num) {Alert (num)//Bounce 123},1000,123)2. Stitching strings (using \)Document.body.innerHTML = ' 55555 '3. Console.log (in console output style%c)var test = 123;Console.log (test); Normal input Log textConsole.log ('%c ' +test, ' color:red;font-size:20px;background:blue ')//output text with style4, typeof (to be called by the form of)var test = 123;typeof Test//numbertypeof (Test)Instanceof, in also have similar use method5, n
obj={A: 2, Foo: Foo} var bar=obj.foo; var a= "Hello" ;bar (); // hello // parameter passing is actually implicitly passed, so we pass in the function is also implicitly assigned the value Span style= "COLOR: #0000ff" >function foo () {console.log ( this .a)} function Dofoo (FN) {fn ();} var obj={A: 2 var bar=obj.foo; var a= "Hello" ;d Ofoo (obj.foo) // hello // callback function missing this binding function foo () { Console.log (this. A)}var obj={ A:2, var
What is offsetwidth?Answer: It can get the value of the object widthSo that's it!HTML sectionPlease look at the above HTML, do you know how much div1 offsetwidth?Isn't it 200?Haha, wrong.Div1 's offsetwidth is 206.Why?A: offsetwidth actually get the box model (Width+border + padding)200+2+4=206Example: Making a div narrowerPhenomenon: onmouseover when the Div narrowsPrinciple:ODiv.style.width = odiv.offsetwidth- 1 + "px";
CSS3 Transition attribute transition, at the end of the animation, there is also an end event: webkittransitionend;Note: Transition, there is only one event.Http://www.runoob.com/jsref/event-transitionend.htmlVuejs Code Snippet:SetTimeout (() = { This. Wrap.classList.add ('swipe-transition'); This. Swipemove (- This. Index * This. PageWidth); Once ( This. Wrap,'Webkittransitionend', _ + = { This. Wrap.classList.remove ('swipe-transition'); //code for Li Chian-hung notes//this.
Tip 1: Use El.contains (e) To determine the area of the clickTip 2: Use MouseUpTip 3: When you are done, remove the eventShowpopover (e) { This. PopOver =! This. PopOvervarClosepopover = (Event) = { if(! This. $refs. PopOver.contains(Event. Target)) { This. PopOver =falseDocument.body.removeEventListener ('MouseUp', Closepopover)} } document.body.addEventListener ('MouseUp', Closepopover)} Warm know new
In JS, the syntax for creating a function object is var myFunction = new Function (arg1,..., agrn, body);where the n parameters of the function object are placed in front of the body of the function body parameter, that is, the function body parameter must be placed at the end of the parameter list, or there can be no parameter new function (body).If you add a third parameter to the last, then "alert (x+= ' aasf ')" will be passed into Func as a param
Object inheritance Inherit
var o = {r:};
var c = function f () {
};
C.prototype = O;
C.R =;
Alert (O.R)//The inherited property value has not changed.alert (C.R);//c in R overwrites the properties in O.
How do I call the R property in O?
var o = {r:};
var c = function f () {
};
C.prototype = O;
Alert (O.R)//The inherited property value has not changed.
alert (C.R);//Query R property, return undefined value.
Calls should be made using prototypes.
The above is a small set to intr
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.