Is it possible to define a event handler of one type of HTML object so that all the instances of this type of objects have this handler? for example, can I create a function func() as the onclick event handler of input text-fields so that all the input-fields have func() as its onclick event handler?
(it’s just something like adding a function to the prototype of a native javascript object.)
No.
Instead, you can handle
onclickfor thedocument, then check ife.target || e.srcElementis an<input>.This is how jQuery’s
.live()works.