Getting the specified elements of the HTML file get the specified element of the HTML file ;p id= "MyTag" > Get HTML file elements body Get html File Elements h2 Get HTML file elements p
[Ctrl + A All SELECT Note: If the
In JavaScript, we can add new attributes or methods to an object by using the prototype keyword, and here is a way to add a binary lookup function for an array object:
Copy Code code as follows:
Array.prototype.binarySearch =
The following demo address is local gray
Local Gray demo Address: http://demo.jb51.net/js/grayscale/index.html
Full Grey demo Address: http://demo.jb51.net/js/grayscale/demo2.htm
How to use:
1. First introduce the Grayscale.js file into the
This may sound a bit messy, don't worry, I will use the example to explain this particular method:
First, we need to understand the concept of the class, JavaScript itself is an object-oriented language, it involves elements depending on their
The test is as follows:
Array type testObject Type TestInstantiating a function testfunction parameter pass test by address
var a=b=[1,2];
A.push (3);
Alert (a.length+ ': ' +b.length);
About the impact on node object operations:
Since
Because it is HTML-formatted content, it is clearly inappropriate to intercept the first few characters of the content directly. And if you remove all HTML format and then intercept and can not achieve the desired effect, and then search the
The code in JavaScript is only one form, or function.
Note: The above words are lowercase and do not confuse JavaScript built-in functions such as number, String, Object, function, and JavaScript language is case-sensitive.
typeof (NULL) returns
Function:
Copy Code code as follows:
Function Throttle (FN,MS) {
var last = (new Date ()). GetTime ();
Return (function () {
var now = (new Date ()). GetTime ();
if (Now-last > ms) {
last = Now;
Fn.apply (this, arguments)
Title: From 1 Add up to 100 and how much?
Non-recursive loop writing:
Copy Code code as follows:
1run:function () {
2 var sum = 0;
3 for (Var i=1;i4 sum = sum + i;
5}
6 console.log (sum);
7}
The recursive
In the writing project will always need to have a lower right corner of the bullet layer prompts the requirements of the bulletin, how to use simpler aspects, more concise code, to achieve a better user experience this is what we want to do content.
First look at the next few days of animation is how to construct JS:
Copy Code code as follows:
var photo=function () {
var index=0,a,b,c,d;
return {
Show:function () {},
Auto:function () {}
}
}
var aa=photo ();
It
click on the button on the page, pop a layer, background dimmed Click on the button on the page, pop a layer, background dimmed
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Note
Window.event Object DifferencesIE: There are window.event objects
FF: No Window.event object. You can pass an event object to a parameter of a function. such as Onmousemove=domousemove (event)
get the current coordinates of the mouse
Ie:event.x
Just now suddenly brainwave, iterators we rarely really directly to the silly next to traverse, then why must realize this stupid next? Directly implement each, so that, in turn, yeah, Itong, soon wrote the first Super Compact version:
Copy
There are figures as follows:
The code is as follows:
Copy Code code as follows:
/*
Head HTML:
Body HTML:
*/
var Tab = function (id,title,url,isclose) {
This.id = ID;
This.title = title;
This.url = URL;
This.head = JQuery ('
A Stream of events (event flow)
The event model is divided into two types: bubbling events, catch events.
Bubble type (dubbed bubbling) Event: The event is triggered from the most accurate object to the most imprecise object in the order of events.
To resolve the conflict between jquery and the $ () function in other JavaScript libraries, the $ () function of jquery needs to be canceled, and jquery provides the following methods:
Copy Code code as follows:
Cancel the $ ()
The first method: Cookie operation class, code encapsulation, the following also have the use of methods, we can refer to the following.
Copy Code code as follows:
String.prototype.Trim = function ()
{
Return This.replace (/^\s+/g, ""
This is the problem I found when I wrote the structure/performance/behavior completely separate tab (JQ version and native JS version). Today, a friend asked me this question, this function is indeed very practical. Share with you my approach to
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.