JQuery Learning (4-1) and jquery learning 4-1

Source: Internet
Author: User

JQuery Learning (4-1) and jquery learning 4-1


Set the form control, mainly including 'verifymail', 'judge whether the input is empty ', and 'set tabindex attribute'

$ (Document ). ready (function () {/* modal windows */$ ('a. modal '). click (function () {var modalID = $ (this ). attr ('rel '); // get the name of the modal/* fade in the modal window and add a close button to it */$ (' # '+ modalID ). fadeIn (). prepend ('<a href = "#" class = "close">  </a> '); /** define the margins so that the mo Dal is centered properly on the screen * we add 80px to the height/width to accomodate for the padding and border * width defined in the css */var modalMarginTop = ($ ('#' + modalID ). height () + 80)/2; var modalMarginLeft = ($ ('#' + modalID ). width () + 80)/2;/* apply the margins to the modal window */$ ('#' + modalID).css ({'margin-top':-modalMarginTop, 'margin-left':-modalMarginLeft });/* Fade in the shade! (Tired of the cheesy jokes yet ?) */$ ('Body '). append ('<div id = "modalShade"> </div>'); // add the shade layer to bottom of the body ('your modalshade'upload.css ('opacity ', 0.6 ). fadeIn (); // set the opacity with jQuery to avoid all of the nasty CSS needed for IE/* focus on the first form input * // ** Syntax: $ (selector ). the each (function (index, element) * method specifies the function to be run for each matching element. false is returned to stop the loop as soon as possible. * // **: Input $ (": input") All <input> elements *: all visible elements of visible * // ** I start from scratch */$ (': input: visible '). each (function (I, e) {/** loop through all visible elements * and assign a tabindex value to each * starting with 0 */$ (e ). attr ('tabindex', 3000 + I) ;});/* apply the focus */$ ('input [tabindex = "3000"] '). focus (); return false; // keep the link from acting naturally});/** close the modal and pull down the shade */$ ('a. close, # modalShade '). live ('click', function () {// clicking on the close or shade layer var thisModalID = $ ('a. close '). parent (). attr ('id'); $ ('# modalShade, #' + thisModalID ). fadeOut (function () {$ ('# modalShade,. close '). remove (); // remove the shade and the close button}); return false;});/* make sure that password is not blank */$ (function () {var passwordLength = $ ('# penewpass '). val (). length; if (passwordLength = 0) {/* make sure warning is on if the length is zero * // ** method returns the next sibling element of the element, only one element is returned */(('{penewpass'{.next('.error'{.css ('display', 'inline');/* when the password changes (and the length grows) turn off error */$ ('# penewpass '). change (function () {comment (this).next('.error'}.css ('display', 'None ');});}}); /* validate e-mail address in register form */$ (function () {/* get length of email */var emailLength = $ ('# email '). val (). length; if (emailLength = 0) {comment ('{email'}.next('.error'}.css ('display', 'inline'); $ ('# email '). change (function () {var regexEmail =/^ [a-zA-Z0-9. _-] + @ [a-zA-Z0-9. -] + \. [a-zA-Z] {2, 4} $/; var inputEmail = $ (this ). val (); var resultEmail = regexEmail. test (inputEmail); if (resultEmail) {response (this%.next('.error'%.css ('display', 'None ');}});}});});

Ren ran has a lot of usage worth learning.


Jquery Learning Method

This is just a Javascript toolkit. There are many methods in it. You can learn Javascript and use jQuery several times later.

What is the basis for learning jQuery? Where is the learning more reliable?

I have been using jQuery for almost a year.
W3School tutorials are the most classic (none) Front-end knowledge repository in China,
To make good use of jQuery, html, css, and javascript must be mastered. It is best to understand the xml-related norms and the DOM basics of HTML.
Note: I am talking about jQuery, which is a collection of javascript class libraries. It is generated to facilitate the development and processing of common and tedious document operations and browser compatibility issues, it would be too unreliable to invest a lot more in learning.

These things have excellent tutorials in W3School,
Baidu: In addition to Baidu encyclopedia entries, HTML, CSS, or javascript, the second is the W3School link.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.