javascript邊角知識

來源:互聯網
上載者:User

標籤:

1.組織預設事件

阻止預設事件,h5預設的input type=‘date‘在某些瀏覽器和android裝置上沒有效果,這時要調用h5+的時間選取器,但是要組織input預設的click事件,代碼如下:

    //選擇時間    $("#end_time").on("click",function(event){        event.preventDefault();        plus.nativeUI.pickDate( 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( "未選擇日期:"+e.message );        },{title:"請選擇到期時間",minDate:new Date()});        });

2.判斷input type=‘checkbox‘ 是否被選中,代碼如下

    if (!$("#shopregister #checkaggree").is(":checked")) {        alert("請同意註冊協議");        return false;    }

3.擷取多個checkbox中被選中的那個的值,代碼如下

<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.擷取多張圖片中title屬性的值

    user.id_pic1 = $($("#shopregister .id_pic")[0]).attr("title");    user.id_pic2 = $($("#shopregister .id_pic")[1]).attr("title");    user.id_pic3 = $($("#shopregister .id_pic")[2]).attr("title");

 5.ajax提交過程中顯示進度圖片

    $.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) {           //服務端成功        }        else {            //服務端失敗        }    }).fail(function () {        //ajax請求失敗    });

 

javascript邊角知識

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.