What is the proper way to uncheck a checkbox in jQuery 1.7?

前端 未结 4 1729
轮回少年
轮回少年 2021-01-05 14:30

I\'m upgrading from jQuery 1.5.1 -- I\'ve read about the \"new\" way to \"check\" checkboxes (in 1.6) using

prop(\"checked\", true);

But w

4条回答
  •  误落风尘
    2021-01-05 15:00

    hiya I though out my comment above will be too much text crammed in so writing it here for clarity: (And I agree with @Claudio)

    If this does not help let me know I will remove my post cheers! :)

    so from here: http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/

    [quote] as of 1.6 i reckon...

    element Value is something else then it’s property or attribute’s value. When you want to uncheck a checkbox, you want to remove the checked property so use $(“#subscribe:checked”).prop(“checked”, false);

    [quote]

    jQuery 1.6+

    Use the new .prop() function:

    $(".myCheckbox").prop("checked", true);

    $(".myCheckbox").prop("checked", false);

    Setting "checked" for a checkbox with jQuery? hope it helps, you are correct I reckon! cheers!

提交回复
热议问题