javascript - Override stepUp and stepDown -



javascript - Override stepUp and stepDown -

is there possibility override html5 stepup , stepdown behaviour? don't want create new buttons, utilize controls provided input. i've been trying override them way:

document.getelementbyid("elemid").stepup = function() { }

but doesn't seem work.

i recommend instead of overriding watch alter event , whatever want.

that beingness said, there 2 ways in can override behavior. suppose next html

<input id="num" type="number" value="0" step="1" min="0" max="100"/>

let's reference number input:

// access spinner var spinner = document.getelementbyid("num");

now if want override stepup() functions, can utilize htmlinputelement object:

// override spinner's setup functions htmlinputelement.prototype.stepup = function(num){ console.log('all overridden: stepping '+num); };

although can override input's stepup() function:

// override spinner's stepup function spinner.stepup = function(num){ console.log('stepping '+num); };

to see illustration of in action open this jsfiddle.

javascript html5

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -