欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery操作復選框checkbox的方法匯總

 更新時間:2015年02月05日 11:23:15   作者:喵小夕  
這篇文章主要介紹了jquery操作復選框checkbox的方法,實例匯總了jQuery針對checkbox進行判斷與賦值的各種常用操作技巧,需要的朋友可以參考下

本文實例匯總了jquery操作復選框checkbox的方法。分享給大家供大家參考。具體分析如下:

jquery判斷checked的三種方法:

復制代碼 代碼如下:
$("input").attr("checked");   //版本1.6+返回:”checked”或”undefined” ,1.5-返回:true或false 
$("input").prop("checked");  //16+:true/false 
$("input").is(":checked");   //所有版本:true/false

jquery賦值checked的幾種寫法:

所有的jquery版本都可以這樣賦值:

復制代碼 代碼如下:
$("input").attr("checked","checked"); 
$("input").attr("checked",true);

jquery1.6+:prop的4種賦值:

復制代碼 代碼如下:
$("input").prop("checked",true); 
$("input").prop({checked:true}); //map鍵值對 
$("input").prop("checked",function(){ 
    return true;//函數(shù)返回true或false 
}); 
$("input").prop("checked","checked");

希望本文所述對大家的jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論