proper event binding cause for soft reject


#1

my item got soft rejected because of

  1. PROPER EVENT BINDING: Consider using the preferred .on() method rather than .click(), .bind(), .hover(), .load(), .ready(), etc. For best performance and concise code use event delegation whenever possible: https://codepen.io/32bitkid/post/understanding-delegated-javascript-events

here is the jquery link.
link-http://hossain.5gbfree.com/divine-creative/js/main.js

how can i solve the matter .i have a small knowledge about jquery.so please help me identify the problem.


#2

Basically what you need to do is: bind all events using the .on() method like selector.on(‘scroll’, callback).

$(’.navbar-collapse a’).on(‘click’,function(){
$(".navbar-collapse").collapse(‘hide’);
});

It can be written like this:
$(’.navbar-collapse’).on(‘click’, ‘a’, function(){
$(".navbar-collapse").collapse(‘hide’);
});

This binds only one event to .navbar-collapse but using the bubbling it trigger on anchor links, and prevents multiple bindings like in your previous version. You bind and event for every anchor which can affect performance in big numbers.