如何选择一个复选框jQuery对象 [英] How to select a checkbox jquery object

查看:85
本文介绍了如何选择一个复选框jQuery对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的jquery对象没有通过$('.checkall').checked = true ;
进行检查 这是小提琴.
更新:工作代码

Why my jquery object didn't get checked with $('.checkall').checked = true ;
Here's a Fiddle.
UPDATE : working code

推荐答案

您需要这样做:

$('.checkall').prop('checked',true);

或者:

$('.checkall')[0].checked = true ;

您可以使用.prop()设置checked的属性,或者直接将jQuery元素转换为HTMLElement,然后直接设置该值.

You would use .prop() to set the property of checked or directly covnert the jQuery element to HTMLElement and then directly set the value.

这篇关于如何选择一个复选框jQuery对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆