javascript - passing this object as argument in onChange event? -
i want make eventhandler passes "this" object parameter. tried this
<select id="customer" onchange="custchange(this);"> it works fine , the dom object on over change called.
but per understanding should not work first argument expected "event" (not "this" object )in event handler method below
<select id="customer" onchange="custchange(event);"> can pass argument(this or event) in eventhandler method provide name correct or first argument considered event object?
you defined custchange , more importantly: you calling it. hence can decide arguments should accept , in order. functions not called you, have pay attention order of arguments.
but if want define custchange compatible other ways of binding event handlers, i.e.
function custchange(event) { // `this` refers dom element } then can call with
custchange.call(this, event);
Comments
Post a Comment