JavaScript Regular Expression Test Web page
How do you normally test regular expressions? Write directly in a large section of code, then wait for the program to run there, and then display the results with alert? Or do you write a page temporarily
Each () is used to iterate through each element and make the appropriate processing, the following is a simple implementation:
Method One (direct function call):
The code is as follows
Copy Code
function each (OBJ,FN)
Let's take a look at the regular rules.
Text
/^ (\d+) $/corresponds to "pure digits"/^ ([a-za-z]+) $/corresponds to "pure letter"/^ ([a-za-z].+) $/corresponds to "beginning of letter + any character"/^ ([0-9a-za-z]+) $/corresponds to "number +
One: ability detection (characteristic detection)
Ability detection is not the ability to identify a particular browser, but to identify the browser.
Two: Eccentricity detection
Unlike the ability to detect, it is mainly to identify browser bugs,
The first, using Math.Round
The code is as follows
Copy Code
var original=28.4531)//round "original" to two decimalsvar result=math.round (original*100)/100; Returns 28.452)//Round "original" to 1 decimalvar
Here's a relatively simple way to realize this: a container demo that sets the width and hides content that extends beyond its width, where demo1 and demo2,demo1 are scrolling content, Demo2 for Demo1 direct cloning, By constantly changing the demo1
The code is as follows
Copy Code
Document.body.offsetWidthDocument.body.offsetHeight
In a browser that declares DOCTYPE, you can use the following to get the browser display window size:
The code is as follows
1, AppendChild
Adds a node to an array of child nodes of the specified node
Usage: target.appendchild (newchild)Newchild inserts the last child node as a child node of target
Take a look at this simple example: Add a child node div at the end of
Performance improvement and analysis of Web page special effects undefined
At work we often need to determine whether a variable/attribute is undefined. There are usually two ways of writing1//Mode 12 typeof age = = ' undefined ';34//Mode 25 Age = =
Web page effects implement XML and string transform each otherThese two functions are more practical ah, you can implement XML and string to transform each other Oh, there is a lot of it to deal with the XML and characters is very convenient.
Test environment (client browser)IE6,IE7, IE8 compatibility mode, IE8Firefox 3.6.8, Google Chrome 5.0.375.125
The standard definitions of two functions are described first.Elementnode.setattribute (Name,value)Name required. Specify the name of the
When a Web page effects object is generated:
such as: function BB (a) {This.a= "KKK"}
var b=new bb ();At this time B is the object has the BB attribute prototype to the prototype object;The prototype object has a constructor attribute pointing to
Array.prototype.binarySearch = function (obj) { var value = 0; var left = 0; var right= this.length; while (left { var center = Math.floor ((left+right)/2); if (this[center] = obj) { value = center; } if (obj { right = center-1; } Else {
JavaScript indexof function with square
Definitions and usageThe IndexOf () method returns the location of the first occurrence of a specified string value in a string.
GrammarStringobject.indexof (searchvalue,fromindex) parameter
Tip: you can modify some code before running Javascript-based WEB editor Sample button Enter the content to edit Another button Click on the button below to select all buttons with the controlRange
// Step 4: sort the columns and related forums. The basic idea is to re-combine the arrays.Function On_OrderUp () {Var CategoryIndex = frmManager. selCategoryName. selectedIndex;Var ForumIndex = frmManager. selForumName. selectedIndex;If
Cart. jsSave it as cart. js and put it in the same directory as the previous html.//------------------------------------------------------------------------------//// File name: cart. js//// Description: Use the javascript function library at the
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.