You can add a click event handler for this:
document.getElementById('button').onclick = function() { alert("button was clicked"); };
This will alert when it’s clicked, if you want to track it for later, just set a variable to true in that function instead of alerting, or variable++
if you want to count the number of clicks, whatever your ultimate use is. You can see an example here.
Related Posts:
- Wait 5 seconds before executing next line
- window.onload vs document.onload
- JavaScript: SyntaxError: missing ) after argument list
- jQuery.click() vs onClick
- What is event bubbling and capturing?
- How to make JavaScript execute after page load?
- jQuery equivalent of JavaScript’s addEventListener method
- What is DOM Event delegation?
- Onclick javascript to make browser go back to previous page?
- How to make JavaScript execute after page load?
- Adding an onclick event to a div element
- Scroll to the top of the page using JavaScript?
- Generate pdf from HTML in div using Javascript
- iFrame onload JavaScript event
- How to terminate the script in JavaScript?
- Fire ontextchanged() event of an asp:TextBox via Javascript
- Get selected value in dropdown list using JavaScript
- Clearing localStorage in javascript?
- How do you Hover in ReactJS? – onMouseLeave not registered during fast hover over
- How to make JavaScript execute after page load?
- How to remove all listeners in an element?
- How to ‘minify’ Javascript code
- ++someVariable vs. someVariable++ in JavaScript
- Get a random item from a JavaScript array
- JavaScript: IIF like statement
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- Is it possible to simulate key press events programmatically?
- Getting DOM element value using pure JavaScript
- How do I select text nodes with jQuery?
- window.onload vs $(document).ready()
- How to get scrollbar position with Javascript?
- Empty functions in Javascript
- Why onbeforeunload event is not firing
- How to make HTML element resizable using pure Javascript?
- window.location.href doesn’t redirect
- How can I capture the right-click event in JavaScript?
- Loop through an array in JavaScript
- Reactjs – Form input validation
- Regex lookahead, lookbehind and atomic groups
- What is lexical scope?
- MIPS fetch address not aligned on word boundary, used .align 4, still no go
- How can I add a key/value pair to a JavaScript object?
- Typescript : Property does not exist on type ‘object’
- Collapse all methods in Visual Studio Code
- How to print elements from array with javascript
- What is the JavaScript version of sleep()?
- How do I scroll to an element using JavaScript?
- What is the difference between memoization and dynamic programming?
- Finding largest integer in an array in JavaScript
- Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
- TypeError: Invalid attempt to spread non-iterable instance
- Declaring multiple variables in JavaScript
- Getting Access Denied when calling the PutObject operation with bucket-level permission
- What is the relationship between PyTorch and Torch?
- git push –force-with-lease vs. –force
- How to add a keyboard listener to my onClick handler?
- GulpUglifyError:Unable to minify JavaScript
- Uncaught TypeError: Cannot read property ‘toUpperCase’ of undefined
- Javascript: difference between a statement and an expression?
- Keep getting a “Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup” when attempting to google plus login on my web app
- Gradient Descent implementation in octave
- The entity name must immediately follow the ‘&’ in the entity reference
- How can I use goto in Javascript?
- What generates the “text file busy” message in Unix?
- How do I programmatically set the value of a select box element using JavaScript?
- Add async script
- How to disable 3.3 Tooltips?
- Force core to use .dev JavaScript files
- WordPress localization
- TinyMCE Button to Insert Multiple Lines of Text?
- How to add extra attributes to the script tag added via wp_localize_script()
- Prevent CSS/JS loading when plugin is not used
- Using an Image Slider twice on the same page
- how to include javascript file and css file in wordpress
- Why is my javascript not invoked in my hooks except wp_head?
- How to place script in footer?
- Why won’t my scripts load?
- Ajax Modal Flickers When Opened Multiple Times
- Password protected Profile View
- Status 400 for AJAX POST Request with admin-ajax.php
- List of JS Events for Widgets?
- Open Featured Image Modal in WordPress Gutenberg onClick of a button
- Theme Javascript.php Overwritten Nightly [closed]
- After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source
- How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?
- The correct way to add a JavaScript in the functions.php [closed]
- Custom JS on a specific page
- Remove Javascript generated by Comments
- wp_enqueue_script JS code runs too late (after user begins interacting)
- wordpress script_loader_tag in function.php
- Javascript not getting injected into page
- Why does my custom plugin only function correctly once per page?
- How do I integrate vanilla Javascript to a wordpress website?
- Where is the Javascript attribute window._wpCustomHeaderSettings defined?
- WordPress Customizer: Check for value of CSS selector and replace it
- Disable flyout (popup) menus in backend
- Adding scripts before plugins scripts
- how to include js in widget?
- How can I use AJAX in child theme template?
- WordPress enque the same script causes the setInterval not to work