jquery - on() to receive param like function instead of event? -


the 1st param of on() might click, mouseenter, etc event, it's possible bind function instead?

$(document).on('click','#box', function(e){     $(this).css('padding-bottom', '32px'); }); 

i want not click apply on #box, can't set 2nd param else because wan't use $(this).. i'm wondering whether 'click' can functions..

yes can add/trigger (non-browser) events in on , see example:

$("p").on("mycustomevent", function(event, myname){   $(this).text(myname + ", hi there!");   $("span")     .stop()     .css("opacity", 1)     .text("myname=" + myname )     .fadein(30)     .fadeout(1000); });  $("button").click(function () {   $("p").trigger("mycustomevent", [ "john" ]); }); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -