jQuery on, add only one event listener -
i have event listener ul:
$('body').on('click.submenu', '.top-level', submenu);
is there way ensure gets added once?
the reason being, need added when viewport @ "mobile" breakpoint, , when goes desktop mobile, there seems more 1 event listener.
var body = $("body"); //store later use if(!(body.data("eventadded") === true)){ //test if event added body.data("eventadded", true) //if not, set eventadded true .on('click.submenu', '.top-level', submenu); //and add event }
Comments
Post a Comment