开发者

jQuery: how to use :checked, if my element is $(this)

开发者 https://www.devze.com 2022-12-28 03:03 出处:网络
how c开发者_C百科an I use the option :checked with $(this) in jQuery ? i.e. $(this:checked) ? thanks$(this).filter(\":checked\");

how c开发者_C百科an I use the option :checked with $(this) in jQuery ?

i.e. $(this:checked) ?

thanks


$(this).filter(":checked");

or if you're testing it

if ($(this).is(":checked")){
    // ...
}


Like this:

if ($(this).is(':checked'))


Use is() method.

$(this).is(':checked') returns boolean.


The checkbox Node has its own property checked, so:

if (this.checked) ...

there is no need to make jQuery do a bunch of work by packaging that trivially simple check in a selector. The DOM version is perfectly readable.


try it $(':checked', $(this))

0

精彩评论

暂无评论...
验证码 换一张
取 消