jQuery: how to use :checked, if my element is $(this)
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))
精彩评论