How to convert this code to coffeescript

Go To StackoverFlow.com

4

I have the following code:

function toggleChecked(status) {
  $(".checkbox").each( function() {
    $(this).attr("checked",status);
  })
}

I don't know how to change the each clause and anonymous function inside it.

2012-04-04 06:33
by Vaibhav Mishra


10

toggleChecked = (status) ->
  $(".checkbox").each ->
    $(this).attr "checked", status

Note that you can use Js2coffee to convert JavaScript into CoffeeScript.

2012-04-04 06:35
by Mathias Bynens
Ads