I have a bunch of elements, and I want to set a click handler for all of them, and then do something based on which one was clicked. For the example you can just have it give an alert stating the class of the button that was clicked. My elements look like this: <input type="button" class="numpad np-txtTP"> and they are all contained in the same element. In my case I want to take whatever is after np-txt and add it to a textbox.
I have a bunch of elements, and I want to set a click handler
Share
will assign a click handler to all input elements within an element of id
containerthat will alert their classnameThis can also easily be done in jQuery in the following way if you have access to it