JavaScript Corner knowledge

Source: Internet
Author: User

1. Organize default events

Block default events, h5 default input type= ' date ' has no effect on some browsers and Android devices, call the h5+ time selector, but organize the input default click event with the following code:

 //  select time  $ ("#end_time"). On ("click"        , function   function   (E) {  var  D = e.date;  //             Console.log (D.format (' yyyy-mm-dd '));         $ ("#end_time"). Val (D.format (' Yyyy-mm-dd '  function   (E) {Console.log ( "not        Select Date: "+e.message); },{title:  Select expiry time, Mindate:new   Date ()        }); });

2. Determine if input type= ' checkbox ' is selected and the code is as follows

    if (!$ ("#shopregister #checkaggree"). Is (": Checked")) {        alert ("Please agree to the registration agreement");         return false ;    }

3. Get the value of the selected one in multiple checkboxes, as shown in the code below

<input name= ' is_refund ' id= ' refund_1 ' type= ' Radio ' value= ' 1 '/><input name= ' is_refund ' id= ' refund_0 ' checked= ' Checked ' type= ' radio ' value= ' 0 '/>$ ("#shopregister input[name= ' is_refund ']:checked '). Val ();

4. Get the value of the title property in multiple pictures

    User.id_pic1 = $ ($ ("#shopregister. Id_pic") [0]). attr ("title");     = $ ($ ("#shopregister. Id_pic") [1]). attr ("title");     = $ ($ ("#shopregister. Id_pic") [2]). attr ("title");

Show progress picture in 5.ajax submission process

$.ajax ({type:' POST ', Url:configManager.RequstUrl+ "/api/user/createstore", Data:postdata, Beforesend:function() {$ ("#waitingupload"). Removeclass ("Heisebghid"). AddClass ("HEISEBG").);} }). Done (function(data) {$ ("#waitingupload"). Removeclass ("HEISEBG"). AddClass ("Heisebghid").); if("success" = =data.state) {//Server success        }        Else{//server failed}}). Fail (function() {//ajax request failed});

JavaScript Corner knowledge

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.