About 101,000 results
Open links in new tab
  1. How to set onClick with JavaScript? - Stack Overflow

    Nov 30, 2012 · 55 I am trying to set the onclick event using javascript. The following code works: var link = document.createElement('a'); link.setAttribute('href', "#"); link.setAttribute('onclick', …

  2. How can I trigger a JavaScript event click - Stack Overflow

    Feb 20, 2020 · To trigger a JavaScript event click, use the dispatchEvent method or jQuery's trigger method.

  3. How to add a onclick event to an element using javascript

    I have created an element using document.getElementsByClassname, and would like to add a onclick event to this element, so that when someone clicks on this element onclick function …

  4. javascript - addEventListener vs onclick - Stack Overflow

    This Stack Overflow page discusses the differences between addEventListener and onclick in JavaScript.

  5. javascript - How to get the onclick calling object? - Stack Overflow

    where e is the "event object" that is passed to the function in browsers other than IE. If you're using jQuery though, I would strongly encourage unobtrusive JavaScript and use jQuery to …

  6. How can I make a button redirect my page to another page?

    May 15, 2013 · 26 Use this: <button onclick="window.location='page_name.php';" value="click here" /> Basically you are using javascript snippet to redirect and onclick event of the button to …

  7. onClick to get the ID of the clicked button - Stack Overflow

    Learn how to get the ID of a clicked button using onClick event in JavaScript.

  8. How to prevent default event handling in an onclick method?

    Aug 14, 2011 · 10 Another way to do that is to use the event object inside the attribute onclick (without the need to add an additional argument to the function to pass the event)

  9. How to call a JS function using OnClick event [duplicate]

    47 You are attempting to attach an event listener function before the element is loaded. Place fun() inside an onload event listener function. Call f1() within this function, as the onclick …

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

    May 21, 2010 · Can we put two JavaScript onclick events in one input type button tag? To call two different functions?