why doesnt this work (function ($) { $("#artist").hover(function() {…
Private research annotation
Sign in to add a private research label or note.
- User
why doesnt this work
(function ($) { $("#artist").hover(function() { $(this).removeClass("grayscale").addClass("color"); }, function() { $(this).removeClass("color").addClass("grayscale"); } })(jQuery); // End of use strict //*/ - Assistant
The issue appears to be related to how the self-invoking anonymous function is closed. Specifically, the curly brace
}that ends the function is not properly matched with a closing parenthesis)before the invocation of the function with(jQuery). This prevents the script from running correctly.Here's a corrected version of your code:
javascript(function ($) { $("#artist").hover(function() { $(this).removeClass("grayscale").addClass("color"); }, function() { $(this).removeClass("color").addClass("grayscale"); }); })(jQuery); // End of use strictKey corrections:
- Added a closing parenthesis after the second callback function to properly end the method's argument list.