AlwaysStudent
AlwaysStudent

Reputation: 1374

Proper event binding

I have a question about proper event binding. I shoved my js code he said

PROPER EVENT BINDING: Consider using the preferred .on() method rather than .click(), .bind(), .hover(), etc.

$(".star").hover(
    function() {
      var prevStars = $(this).prevAll();
      prevStars.toggleClass('rate-btn-hover');
    }
  );
$("body").on("click", ".star", function() {
  $(this).siblings().removeClass('rate-btn-active')
  var prevStars = $(this).prevAll().addBack();
  prevStars.addClass('rate-btn-active');
});

Can anyone tell me what that means ?

Upvotes: 2

Views: 297

Answers (1)

guest271314
guest271314

Reputation: 1

The text of the message is suggesting substituting

.on("mouseeneter", handleEvent)

for

.hover(handleEvent)

Upvotes: 1

Related Questions