+ 1

Can we do 2 events with the same code?

Hi, is it possible to do 2 events and using the same code on the 2 events without always copy and paste on each events? https://code.sololearn.com/WGUbtC2RFEno/?ref=app

29th Sep 2018, 8:06 PM
Spider38E
Spider38E - avatar
4 ответов
+ 2
var myKeyUpHandler= function(){ ...... }; myVar1.keyup(myKeyUpHandler); myVar2.keyup(myKeyUpHandler);
29th Sep 2018, 9:18 PM
KrOW
KrOW - avatar
+ 2
Thank you :)
29th Sep 2018, 9:30 PM
Spider38E
Spider38E - avatar
+ 1
function do_something(_this){ // do something with _this alert("test"); } $("input").live("keyup", function({ do_something($(this)); }); $("select").live("change", function({ do_something($(this)); });
4th Oct 2018, 9:19 AM
ASWATHI KISHAN P
ASWATHI KISHAN P - avatar
0
👍👍👍
29th Sep 2018, 9:32 PM
KrOW
KrOW - avatar