radio与checkbox的选中事件

<一>判断checkbox的选中事件
var result=$(this).find("input[type='checkbox']").prop("checked");
result 是bool类型的值 true是选中的状态 false是没选中的状态

checkbox标签已有checked=checked但是不显示勾选

if(dataBack.remind){     $("#isremind").prop("checked",true); }else{     $("#isremind").removeAttr("checked"); }

添加的时候用prop,取消用removeAttr。


<二>radio的选中状态

    //付款方式
    $('div#pay-type input[type="radio"] ').each(function (e) {
        var radiotype = $(this).attr("checked");
        if (radiotype == "checked") {
            paytype = $(this).attr("tid");
        }
    });


   var radiotype = $(this).attr("checked");
如果radiotype == "checked" 就是选中

find就相当与children  
closet就相当于parent

 

posted @ 2015-04-13 14:31  逍遥帝君  阅读(1412)  评论(0编辑  收藏  举报