Common Operations of JS and Jquery

Source: Internet
Author: User

String truncation:

  1. Substr ()
  2. Substring ()
  3. Slice ()

String segmentation, merging, and search

  1. Split ()
  2. Concat ()
  3. IndexOf ()
  4. CharAt ()
  5. Replace ()
  6. Search ()

String case-sensitive Conversion

  1. ToLowerCase ()
  2. ToUpperCase ()

Jquery Checkbox selection judgment:

   1: jQuery(‘input[@name=checkbox1][@checked]’).each(funcion(){

   2:     if($(this).attr("checked")==true){

   3:         //TODO:

   4:     }

   5: })

   6:  

JQuery Radio selected:

$ ('Input [@ name = gender] [@ checked] '). val ();

Select is simple. val. Or: $ ("select option: selected ")

DOM operations

$ (). Find ()

$ (). Children ()

$ (). Parent ()

Regular Expression:

Mobile phone number:/^ (13 [0-9]) | (15 [^ 4, \ D]) | (18 [-9]) \ d {8} $/

Phone number:/^ (\ d {3, 4} \) | \ d {3, 4}-| \ s )*? \ D {7, 11} $/

Email:/^ \ w + (-\ w +) | (\. \ w +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/s

HtmlDecode

 1  var s = "";   
2 if (str.length == 0) return "";
3 s = str.replace(/&/g, ">");
4 s = s.replace(/</g, "&lt;");
5 s = s.replace(/>/g, "&gt;");
6 s = s.replace(/ /g, "&nbsp;");
7 s = s.replace(/\'/g, "'");
8 s = s.replace(/\"/g, "&quot;");
9 s = s.replace(/\n/g, "<br>");
10 alert(s);
11 return s;

Super invincible domestic phone number + mobile phone number regular match:

/(^ (\ (0 \ d {2, 3} \) | 0 \ d {2, 3}-| (0 [12] \ d) | (0 [3-9] \ d {2}) \ d {7, 8} $) | (^ (13 [0-9]) | (15 [^ 4, \ D]) | (18 [0-9]) \ d {8 }$) | (^ \ d {7, 8} $ )/

Supported telephone formats such as (010), 010-, 010xxx (7-8), 13XXX, 15XXX, and 18XXX

Email regular:

/^ \ W + (-\ w +) | (\. \ w +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/

Mobile phone Regular Expression: refer to the first regular expression.

 

Will be supplemented later...

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.