Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 656
Vaibhav Mishra Avatar asked Dec 27 '22 03:12

Vaibhav Mishra


1 Answers

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

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

like image 185
Mathias Bynens Avatar answered Jan 10 '23 00:01

Mathias Bynens