Just like any other click event, you can use jQuery to register an element, set an id to the element and listen to events like so:
$('#myButton').on('click', function(event) { event.preventDefault(); // To prevent following the link (optional) ... });
You can also use inline javascript in the onclick attribute:
<a ... onclick="myFunc();">..</a>
Related Posts:
- Bootstrap Dropdown menu is not working
- How does the data-toggle attribute work? (What’s its API?)
- Adding images to a Bootstrap Carousel with AJAX
- ChangeDate – Date Picker Bootstrap
- Understanding how data-dismiss attribute works in Bootstrap
- bootstrap-datetimepicker for bootstrap 4
- TypeError: $(…).modal is not a function with bootstrap Modal
- Bootstrap popover is not working
- Bootstrap modal – close modal when “call to action” button is clicked
- Creating Accordion Table with Bootstrap
- How to open a Bootstrap modal window using jQuery?
- Closing Bootstrap modal onclick
- Bootstrap Collapse not Collapsing
- Enqueueing a script and a style sheet not working
- Masonry grid with bootstrap 4
- map function for objects (instead of arrays)
- Check if a string has a certain piece of text [duplicate]
- How to convert a string to an integer in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- window.location.href and window.open () methods in JavaScript
- “document.getElementByClass is not a function”
- How to create an associative array in JavaScript literal notation
- Include another HTML file in a HTML file
- Cannot open local file – Chrome: Not allowed to load local resource
- How to read a local text file?
- Compare dates with javascript
- Javascript Uncaught SyntaxError: Unexpected identifier
- “document.getElementByClass is not a function”
- What’s the best way to convert a number to a string in JavaScript?
- React Native: this.setState is not a function
- How to perform string interpolation in TypeScript?
- forEach is not a function error with JavaScript array
- Short circuit Array.forEach like calling break
- How do I format date in jQuery datetimepicker?
- Express Render not working return error: No default engine was specified and no extension was provided
- Remove Object from Array using JavaScript
- Angular4 – No value accessor for form control
- What is the difference between ( for… in ) and ( for… of ) statements?
- TypeError: Cannot read property “0” from undefined
- How to use npm jquery module?
- Jquery swipe left or right on mobile
- Cannot read property ‘bind’ of undefined. React.js
- Why is my asynchronous function returning Promise {
} instead of a value? - NodeJs : TypeError: require(…) is not a function
- Sort array by firstname (alphabetically) in Javascript
- Sorting arrays in javascript by object key value
- How do I get an element to scroll into view, using jQuery?
- document.getElementById not working / Display
- jQuery: Check if div with certain class name exists
- Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- How to get height of div in px dimension
- jQuery: Uncaught Error: Syntax error, unrecognized expression
- What is the difference between String.slice and String.substring?
- How to use in jQuery :not and hasClass() to get a specific element without a class
- Crop the image using JavaScript
- What is the best way to remove a table row with jQuery?
- Adjust width and height of iframe to fit with content in it
- document.getElementbyId() returning null
- Only on Firefox “Loading failed for the script with source”
- How do you use a variable in a regular expression?
- How to embed a youtube playlist with a sidebar
- How to add a button dynamically using jquery
- External JavaScript Not Running, does not write to document
- Create a simple 10 second countdown
- Generate a Hash from string in Javascript
- jQuery if Element has an ID?
- Get name of object or class
- Complex JSON nesting of objects and arrays
- Find a value in an array of objects in Javascript [duplicate]
- What does `node –harmony` do?
- AngularJS POST Fails: Response for preflight has invalid HTTP status code 404
- What does wp-list.js do?
- Preventing YouTube embeds loading multiple instances of player JS?
- How to combine javascript files without plugins?
- WordPress Errors? Update Failed! data.min.js
- How to handle malformed response from WP REST API?
- Use useSelect/useDispatch instead of withSelect/withDispatch
- Trouble adding JavaScript in visual editor (Sharpspring embed code)
- Modals using loops and ACF [closed]
- Changes to JS not reflected on site
- How to set translations in javascripts for my plugin?
- How to make wordpress URLS google friendly for ajax driven sites?
- js addclass function not working as expected, intereaction or special WP somethign needed?
- Get a default value of the Customizer setting using wp.customize API (JS)
- Google PageSpeed Enable Compression isn’t working?
- How can I add Javascript in the header of all post pages and only post pages
- wp_enqueue_script not loading my custom js file
- Javascript alert appears before tag
- Add captcha validation to my custom form for Frontend posting
- AddThis Sharing Bar Not Displaying on Custom Page Template – JS conflict?
- Bootstrap bundle present in page source but not working
- Web cover page open when button clicked
- Add JavaScript-Library “Fitty” to WordPress
- Access checks with custom REST endpoints and backbone
- How to pass data to javascript in custom widget class
- jQuery + more won’t load in header
- How to add additional JavaScript code [duplicate]
- JavaScript errors
- Unable to change the location of a file