简体   繁体   English

在coffeescript中使用$(this)

[英]Using $(this) in coffeescript

just a quick one. 只是一个快速的。 How is it possible to use jQuery $(this) in Coffeescript : 如何在Coffeescript中使用jQuery $(this)

$ 'input'
 .on 'click', (e) ->
  alert 'test' if $ 'this'
   .is(':checked')

can't get it to work. 无法使其正常工作。

$('input').on('click', 
  (e) ->
   if $(this).is(':checked')
     alert('test')
)

':checked' not :checked ':checked'不是:checked

use paranthesis - it will save your time. 使用括号-可以节省您的时间。 Trust me. 相信我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM