3

jquery判断checkbox是否被选中的方法

 2 years ago
source link: https://blog.p2hp.com/archives/9191
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

jquery判断checkbox是否被选中的方法 | Lenix Blog

方法:1、获取checkbox元素,然后使用“get(0).checked)”方式进行判断;2、获取元素,然后使用“is(':checked')”方式进行判断;3、获取元素,然后使用“ttr('checked')”方式进行判断。

jQuery 判断 checkbox 是否被选中的几种方法

if ($("#checkbox-id")get(0).checked) {
    // do something
}
if($('#checkbox-id').is(':checked')) {
    // do something
}
if ($('#checkbox-id').attr('checked')) {
    // do something
}
1234567
891011121314
15161718192021
22232425262728
293031  
« 7月    

归档

日志总数:2058篇 评论总数:203条
分类总数:26个 标签总数:324个
友情链接:15个 网站运行:3832天
最后更新:2022年7月31日

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK