Recently, every day to do a paper issue report, a moment itched, design the web again, suddenly encountered a problem, the previous design of the Web page is in IE ran, never considered Firefox, not to mention Chrome, but now different, At least I think the incompatible Firefox Web page is extremely ugly and cottage, so from the beginning of this concept, I design the page began to pay attention to this compatibility, and this time encountered a compatibility problem, HTML inside a floating fram
asort an array of objectsThe ordering of an array of objects is typically sorted according to the value of one or more keys in the object.With the introduction of the above custom collation ordering, it is not difficult to sort the array of objects.Or an example: var jsarray = [{id:1,score:100}, {id:2,score:2}, {id:3,score:4}, {id:4,score:30}]; Jsarray.sort (function (A, b) {return a["score"]>b["Score"]?1:-1}); Test for (va
"). empty ();//Empty drop-down boxGets the value of a set of radio selected itemsvar item = $ (' input[@name =items][@checked] '). Val ();Gets the text of the Select selected itemvar item = $ ("select[@name =items] option[@selected]"). Text ();The second element of the Select drop-down box is the currently selected value$ (' #select_id ') [0].selectedindex = 1;Radio the second element of a radio group is the currently selected value$ (' input[@name =items] '). Get (1). checked = true;Get Value:t
Multiple sites need to fill in the text box by default will give a default language, when the mouse clicks the text box can be the inside of the default text to clear, when the text is deleted and the focus left the text box when the default text to the text box.
The code is as follows:
The above code implements our request, when clicks the text box to be able to clear the text box the content, if the text box does not enter any content, this time the mouse focus leaves the text b
function Ismail (name)/e-mail value detection{if (! Isenglish (name))return false;i = Name.indexof ("at");j = Name Dot LastIndexOf ("at");if (i = = 1)return false;if (i!= j)return false;if (i = = Name dot length)return false;return true;}
jquery Verification Mailbox
function Checkemail ()
{
var temp = document.getElementById ("Tbemail");//This sentence can be replaced with the following
var temp = $ ("#tbemail");
Verification of e-mail
var myreg =/^ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+@
Although it is now possible to transfer files to the server in a browser by using a form, especially the form control, this thing can only pass one file at a time. If the user needs to upload the entire album or more pictures, then the technical staff had to think of other ways, such as Flash or JS. But now, with the new tags provided by HTML5, we can totally do without the extra stuff. HTML5 provides several new tags for uploading files, such as mul
Write any programming code, different developers will have different views. But the reference is always good, the following is from the Javascript Toolbox released 14 best JS Code writing techniques , sofish translation (1,2).
1. Always use ' var '
In JavaScript, a variable is not a global scope is a function range, the use of "var" keyword is to keep the variables concise and clear key. When declaring a variable that is either global or a function
javascript|js| Dynamic I now have a layer, there is a div in the layer, when the content is more often appear in the scroll bar, I now think, when the scroll bar appears, the width of the table div is equal to the width of the div minus the width of the scroll bar, how to dynamically get the width of the scroll bar, Or to determine whether the state of the scroll bar appears.
----------------------------------------------------------------------------
Alert ("ABACACF". Replace (' A ', ' 9 '));
Alert ("ABACACF". Replace (/a/g, ' 9 '));
The first run results 9BACAF This just replaces the first
The result of the second operation 9b9c9f This can realize all the substitution function of JS
In fact, the second meaning is to implement the global substitution with regular expressions G represents gobal
Additional: Global substitution with special symbols
Copy Code code as follows:
Onclick=
The code is very simple, it is not a lot of nonsense.
Copy Code code as follows:
The first way of defining
var person=new Object (); An object was created.
Person.name= "Tom"; Call the Name property with the person object, and its value is Tom
alert (person.name); Show Name property value
Person.say=function () {//Adds a say function to the person object.
Alert ("person say");
};
Person.say ();
Copy Code code as follows:
The second way of
Load the js dependency module according to the configuration file, and configure the file js dependency
Requirements:
According to the following configuration fileCopy codeThe Code is as follows:Module = [{'Name': 'jquery ', 'src':'/js/lib/jquery-1.8.3.js '},{'Name': 'swfobobject', 'src': '/
Detailed description of LABJS dynamic loading of js files on demand, detailed description of labjs dynamic js
LABjs is a small JavaScript tool used to load JavaScript files as needed. Using this tool can improve page performance and avoid loading unnecessary JavaScript files, you can dynamically and concurrently load script files and manage the execution sequence of loaded script files.
Simple Example
$LAB.
My 2nd week with node. JS-node. JS Bottom Book last time: "My first week with node. JS-node. JS style features." This time I read some things about the underlying implementation:
Depth 3rd asynchronous I/O-How does node. JS implement asynchronous I/O
Udemy "Lear
Fine read this article, enough for you to optimize a half-day, about the JS optimization methods are mostly out of these three methods.
(Total page size is 155.k, and JS takes up 100.3K)
It's time to optimize the next JS.
About JS optimization of the article has a lot of, mostly technical very strong, like what var
In-depth understanding of JS engine execution mechanism
Why is 1.JS single-threaded? Why is async required? How is a single thread implemented asynchronously?
Event loop in 2.JS (1)
Event loop in 3.JS (2)
4. Talk about SetTimeout
First, keep in mind 2 points:(1)
Install node. jsThis is very simple, download down, configure the environment variable on it, use NODE-V to see if the installation is successful
The modules required to install the compression are Uglify-js,clean-css,node-smushit
The command is NPM install XXX, I installed before is not suitable for the global installation, this should not matter
Write compressed JS (should look
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.