This is a simple example. But it's a lot of places to use.A simple plug-in on the City of encapsulation 1 --> 2 type = "text" ID = "Re_email" /> input type = "button" ID = "Getyzm" value = "Get Verification Code" > 1Instance Address: Http://files.cnblogs.com/files/lyqweb/Countdown.rar(JQ plugin) Get Verification code
Only numbers can be entered$ ('. Text '). KeyUp (function () {$ (this). Val ($ (this). Val (). replace (/^0+/g, ""). Replace (/[^0-9]/g, "))})Enter numbers and decimals (accurate to two digits after the decimal point)$ ('. Text '). KeyUp (function () {var number = $ (this). Val (). replace (/^\./g, ""). replace (/[^\d.) /g, ""). replace (".", "$#$"). replace (/\./g, ""). replace ("$#$", "."). Replace (/^ (\-) * (\d+) \. ( \d\d). *$/, ' $1$2.$3 ')$ (this). Val (number);})
Several common uses of each of the jquery methodsEach () method makes the DOM loop structure concise, traversing one-dimensional arrays, multidimensional arrays, DOM, JSON, and so on.var arr = ["One", "one", "three", "four"]; function() { alert ( ThisThe results for each of the above outputs are: One,two,three,fourvar arr1 = [[1, 4, 3], [4, 6, 6], [7,, 9]] function(i, item) { alert (item[0]); }); In fact, ARR1 is a two-dimensional array, item is equivalent to
()
Gets the ancestor element of each element in the current matching element collection, optionally filtered by the selector.
. Parentsuntil ()
Gets the ancestor element of each element in the current matching element collection until it encounters an element that matches the selector.
. Prev ()
Gets the previous sibling element immediately adjacent to each element in the matching element collection, optionally filtered by the selector.
.
$ (' H1 '). Click (function () {var index = $ (this). index (); $ ('. Content '). EQ (index). Show (). addclass (' active '). Siblings (). Removeclass (' active '). Hide ();});Use the index to identify the click of the subscript is the click of the number of points, and then use the EQ to put this index number in, so that you click on the one by one corresponding, equivalent to binding, show addclass what to say, Siblings is to say that in addition to the other points in your selection, such as
,Hovercolor: "Black" }; VarOptions=$.Extend(Defaults,Options); Return This.each(function () { VarO=Options; Assigning an element collection to a variable in this case, the UL object VarObj=$(This); Get the A object in UL VarItems=$("Li a",Obj); Add hover () event to aItems.Hover(function () {$(This).Css("Color",O.Hovercolor); Queue false means not added to the animation queue$(This).Animate({Paddingleft:O.Animatepadding}, {Queue: False,Duration: 300 }); }, function () {$(This).Css("Color", "");$
DOCTYPE HTML>HTMLLang= "en">Head>MetaCharSet= "UTF-8">title>JQ subtitle Typing effecttitle>style>*{margin:0;padding:0;}Body{Background-color:#000;Color:#00FF00;padding:100px;font-size:30px;}. Hide{Display:None;}style>Head>Body>div for output text -DivID= "Showbox">Div>text that you want to output -Divclass= "Hide"ID= "Contowrite">Login:usernameBR>Password: ******BR>Access is grantedBR>What about Chinese? Div>Scriptsrc= "Http://www.lamahui.com/static/1
) Deferred.fail () specifies the callback function when the operation fails(4) Deferred.promise () when there are no parameters, the function is to keep the running state of the deferred object unchanged; When the parameter is accepted, the role is to deploy the deferred interface on the Parameter object.(5) Deferred.resolve () manually changes the running state of the deferred object to "completed", triggering the Done () method immediately.(6) $.when () specifies a callback function for multip
Today on the Internet to see an article, about JQ inside the difference between the event binding, said I look after the understanding, I rookie a, a lot of things do not understand, there is a wrong understanding of the great gods and more adviceThe bind () method is the most straightforward method of binding an event, which is the longest-lasting method of binding to the document, and it solves the compatibility problem well.Advantages of the Bind (
1. Query based on the ID selector and use the Find method.1 // Fast 2 $ ("#container div.footer"); 3 4 // super fast 5 $ ("#container"). Find ("Div.footer");Using the Find method reduces the time it takes to traverse a node.2, when using the hybrid selector, the selector on the right is best to be specific.1 // before optimization 2 $ ("Div.data. Footer"); 3 4 // after optimization 5 $ (". Data Div.footer");On the left, it is best to use a selector such as tag or class, preferably on the right w
Recently, I have been thinking about JQ in the project, so some of my experiences have been put up in a timely manner. I would like to ask you if I have any questions.
In the project, the left menu is folded and displayed, which is common in the software interface (originally copy a section on the InternetCodeThis is the case. It is estimated that the writing is better than me, but learning requires a Learning Spirit ^ !),
I used. animate () to hi
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.