Vaibhav Mishra
Vaibhav Mishra

Reputation: 12102

How to convert this code to coffeescript

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.

Upvotes: 4

Views: 3024

Answers (1)

Mathias Bynens
Mathias Bynens

Reputation: 149524

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

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

Upvotes: 10

Related Questions