Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to code comma separated functions inside jQuery event, into CoffeeScript
    primarykey
    data
    text
    <p>I'm new to coffeescript, and while there is extensive information concerning the proper method of coding vanilla javascript in coffeescript, there is little information concerning how to code jQuery in coffeescript.</p> <p>If someone could explain how to code the comma separated functions inside this jQuery hover event, as coffee script, it would be greatly appreciated.</p> <pre><code>$(".sprite-image.btn-rest").hover( function () { $(this).removeClass('btn-rest').addClass('btn-hover'); }, function () { $(this).removeClass('btn-hover').addClass('btn-rest'); $(this).parent().prev().children('.sprite-image.btn-rest_before_activecurrent').removeClass('btn-rest_before_activecurrent').addClass('btn-rest'); $(this).parent().prev('.sprite-image.nav_spacer_1-activecurrent').removeClass('nav_spacer_1-activecurrent').addClass('nav_spacer_1-rest'); } ); </code></pre> <hr> <p>In response to the correct answer posted below by Larry Battle, I am posting the correction I made to Larry's original coffeescript <em>before</em> he made his correction.</p> <pre><code>$('.sprite-image.btn-rest').hover -&gt; $(this).removeClass('btn-rest').addClass 'btn-hover' , -&gt; $(this).removeClass('btn-hover').addClass 'btn-rest' $(this).parent().prev().children('.sprite-image.btn-rest_before_activecurrent').removeClass('btn-rest_before_activecurrent').addClass 'btn-rest' $(this).parent().prev('.sprite-image.nav_spacer_1-activecurrent').removeClass('nav_spacer_1-activecurrent').addClass 'nav_spacer_1-rest' </code></pre> <p>I'm curious because this coffeescript produced the same result as his corrected answer. My question: Is one better than the other? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload