Implement a simple on and off method
Introduced:
Event object:
Funclist: {},//Save Delegate bound methodIefunclist: {}//Save the binding method under IE
The on and off method in the Event object, the main callEvent.addevent, Event.delegatehandle
Now there is a demand for the following figure:
Product manager said card number can only let input numbers (the middle of the space is the format of the added, but also with JS), sometimes my mind appeared a voice, what things, add a type=number
There are two ways that JavaScript defines regular expressions.
1.REGEXP Constructors
var pattern = new RegExp ("[Bc]at", "I");
It receives two parameters: one is the string pattern to match, and the other is the optional flag string.
2. Literal
This example describes a workaround that JavaScript code in the thinkphp controller cannot perform. Share to everyone for your reference. The specific methods are as follows:
Here example analysis of thinkphp in the controller of the Web page
Now there is a demand for the following figure:
Product manager said card number can only let input numbers (the middle of the space is the format of the added, but also with JS), sometimes my mind appeared a voice, what things, add a type=number
& Lt;meta http-equiv= "Content-type" content= "text/html; Charset=iso-8859-1 > Press ENTER to jump to next control 123< ;/option> 456
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to
For example, you cannot use this invocation method: Element.onclick = Test (); Element.onclick = Test (ARG1,ARG2), only through Element.onclick = function () {...}; or Element.onclick = Test is implemented in this way, so arguments cannot be passed
The example in this article describes the way JavaScript implements the scroll bar effect. Share to everyone for your reference. as follows:
* {margin:0;
padding:0;
} #div1 ul{Position:absolute;
left:0px;
top:0px;
#div1
In JavaScript, there are two ways to block the default submission behavior of a form, namely:
(1) return False
Sample code
Submit
(2) using Preventdefault ()
In standard browsers, the default behavior of the browser is blocked,
Principle: Using InnerText or InnerHTML
Copy Code code as follows:
Test
InnerText and innerHTML are two non-dom standard methods.
The difference is as shown in the figure:
(The figure should be innertext)
In IE,
A command to display information
The code is as follows:
Common console command
The most common is the console.log.
Two: Placeholder
Console The above centralization supports printf placeholder formatting, supported
After learning the traditional object-oriented language, such as Java C + +, transfer JavaScript is a bit inappropriate, especially in JavaScript, the so-called object function (function), sometimes get dizzy. The following conceptual things are
Untitled function diff () {var s = f.s1.value;
var S1 = F.s2.value;
document.write ("s:" + S + "");
document.write ("S1:" + S1 + "");
function sort (s, a) {for (i=0 i List1[n]) {l[j] = List1[n];
if (n
[Ctrl + A All SELECT
Example:
1. The contents of the a.html document are as follows:
Browse b.html
2. The contents of the b.html document are as follows:
3. When accessing b.html through hyperlinks in a.html, the results are
Quick sort, also called dividing exchange sort. A fast sorting algorithm based on the method of divide and conquer.
This paper is mainly about the use of JavaScript to achieve the rapid ordering of in-place ideas
Divided by the rule of law:
In
Globalstorage
This is also proposed in the HTML5, after the browser is closed, the use of globalstorage stored information can still be retained, and storage capacity than IE userdata much larger, a domain below 5120k. As with Sessionstorage, the
There are a number of methods, two:
First: (Through the charCodeAt method of the string object)
Copy Code code as follows:
String.prototype.getBytesLength = function () {
var length = 0;
for (i = 0;i Icode = This.charcodeat (i);
To all of you, to do online listening to songs, without their, because the use of the external jquery.js file, so run the code after the page to refresh the effective!
listening to song Search:
[Ctrl + A All SELECT
function: Split ()Function: To store a string partition into an array using a specified delimiterExample:Str= "Jpg|bmp|gif|ico|png";Arr=thestring.split ("|");Arr is an array that contains the character values "JPG", "BMP", "GIF", "ico", and
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.