在coffeescript中使用$(this)

Using $(this) in coffeescript

本文关键字:this coffeescript      更新时间:2023-09-26

就一个。如何在Coffeescript中使用jQuery $(this):

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

不能让它工作

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

':checked' not :checked

使用括号-这将节省你的时间。相信我。