About 76,200 results
Open links in new tab
  1. html - Add event to button with javascript - Stack Overflow

    Feb 4, 2010 · In this page there's a way to dynamic add html (textbox,input button and radio elements with javascript. my questioon is how can i add an event to the button, imagine that i only want create the button, not the textbox or the radio element. UPDATE I'm having problems here...

  2. How to add event handlers to HTML buttons from within …

    Mar 1, 2012 · Use element.addEventListener() (originating from the DOM 2 Events spec). In your case it will be In your case it will be document.getElementById("18").addEventListener("click", squareWasClicked, false);

  3. javascript - OnChange event handler for radio button (INPUT …

    @Matthew: The onclick handler is just named poorly -- it handles the event of radio button selection whether the button is clicked, touched, or activated by hitting "enter" on a keyboard. The onchange handler is not appropriate in this case since the value of the input does not change, only the checked/unchecked attribute.

  4. javascript - Radio Buttons onChange event - Stack Overflow

    Aug 2, 2020 · This is how radio buttons are designed to work. According to the spec, only a single input and change event is fired on the radio button in the radio button group. MDN states this is another way: Depending on the kind of element being changed and the way the user interacts with the element, the change event fires at a different moment:

  5. How do you catch a click event with plain Javascript?

    Oct 26, 2011 · I would recommend going with addEventListener instead of assigning the handler function directly.. var div = document.getElementById('test'); div.addEventListener ...

  6. Can I have two JavaScript onclick events in one element?

    Jul 12, 2011 · the downside of this method is that the context here will be the global window object and "this" would not work inside myOther.... declaration, this just refers the function and do not attach it to the onclick property of the element, it is worth to explain this.

  7. javascript - addEventListener vs onclick - Stack Overflow

    First when you try to hook up the events in this way button.onclick = function(), onclick event will be triggered by clicking the button, however, the button will not be disabled because there's no explicit binding between button.onclick and onclick event handler.

  8. javascript - How to Detect Browser Back Button event - Stack …

    Jul 8, 2016 · history entry changes both in "back" and "forward" button events (So none of the answers here really defect only "back" button). window.addEventListener('popstate', () => { console.log('User clicked back button -or- forward button -or- …

  9. javascript - adding multiple event listeners to one element - Stack ...

    So my dilemma is that I don't want to write the same code twice. Once for the click event and another for the touchstart event. Here is the original code: document.getElementById('first').

  10. How to call multiple JavaScript functions in onclick event?

    Oct 11, 2010 · const callDouble = =>{ increaseHandler(); addToBasket(); } <button onClick={callDouble} > Click </button> It's worked for me, you can call multiple functions in a single function. then call that single function.

Refresh