JS and JQuery Event Handler


#1

I am not certain the reasons why this code isn't working at all;
here is the link and the instructions below it.

https://www.codecademy.com/skills/make-an-interactive-website/topics/jquery-events/jquery-click-try

Fill in the event handler below to apply the class "btn-like" to the $(".btn") element. Use .toggleClass() to apply the class. Use this to operate on the already-selected HTML element.

var main = function() {
$(".btn-like").click(function() {
$(this).toggleClass("active");

});
};

$(document).ready(main);

the console does not respond.

Please help, thank you in advance!


#2

the link of the lesson that you tell you just to put $(".btn").click(function()

var main = function() {
  $(".btn").click(function() {


  });
};

$(document).ready(main);

and the next one to put $(this).toggleClass("active ")


#3

@_antimatter_,
@antimatter_,

Fill in the event handler below to apply the class "btn-like". Use .toggleClass() to apply the class.

Use $(this) to operate on the already-selected HTML element with $(".btn")


#4

Thank you. it helped.


#5

Right, thanks. it worked! You guys are great.


#6

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.