Here’s what I cooked up. It’s pretty simple, but it works:
function eventFire(el, etype){ if (el.fireEvent) { el.fireEvent('on' + etype); } else { var evObj = document.createEvent('Events'); evObj.initEvent(etype, true, false); el.dispatchEvent(evObj); } }
Usage:
eventFire(document.getElementById('mytest1'), 'click');
Related Posts:
- ChartJS beginAtZero, min, max doesn’t work
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- ReferenceError: $ is not defined
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- JS/Ionic:TypeError: Cannot read property ‘code’ of undefined
- Axios Delete request with body and headers?
- How to deal with floating point number precision in JavaScript?
- What’s a maximum call stack size exceeded error and how to fix it?
- NPM ELIFECYCLE error – using node server.js command
- React Hook Warnings for async function in useEffect: useEffect function must return a cleanup function or nothing
- Change Background color (css property) using Jquery
- jQuery get textarea text
- Base64 encoding and decoding in client-side Javascript
- Response to preflight request doesn’t pass access control check
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- How to clear the canvas for redrawing
- No value accessor for form control
- React eslint error missing in props validation
- How to specify multiple conditions in an if statement in javascript
- Mongoose – What does the exec function do?
- Find an element in DOM based on an attribute value
- character counter – backspace doesn’t reflect on characters remaining
- How does the double exclamation (!!) work in javascript?
- Add days to JavaScript Date
- illegal use of break statement; javascript
- Open URL in same window and in same tab
- Cannot read property ‘getContext’ of null, using canvas
- How to add multiple classes to a ReactJS Component?
- Make Axios send cookies in its requests automatically
- How to move an element after another element using JS or jquery?
- Converting any string into camel case
- Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
- How to use Javascript to read local text file and read line by line?
- Why is the jquery script not working?
- JSON.parse() not working
- Call python function from JS
- How to add onload event to a div element
- Access Control Origin Header error using Axios
- Structs in Javascript
- Refused to execute script, strict MIME type checking is enabled?
- Error: [ng:areq] from angular controller
- getElementsByAttribute() is not a function
- Javascript onload not working
- How to parse float with two decimal places in javascript?
- Checking for duplicate strings in JavaScript array
- Load Image from javascript
- Most efficient method to groupby on an array of objects
- Don’t make functions within a loop [duplicate]
- Difference between ?:, ?! and ?=
- JavaScript post request like a form submit
- Jest encountered an unexpected token
- JavaScript – Count Number of Visitor for Website
- Jquery Value match Regex
- replace space with dash JavaScript
- Using “×” word in html changes to ×
- How do I store an array in localStorage?
- How to check if the URL contains a given string?
- How to enable CORS in AngularJs
- bootstrap buttons onclick events
- Uncaught SyntaxError: Unexpected token var
- window.location.href doesn’t redirect
- DeprecationWarning: Calling an asynchronous function without callback is deprecated. – how to find where the “function:” is?
- What are the benefits of using wp_enqueue_script?
- Filter medias from the Media Uploader (wp.media) modal with a post meta
- Create user from outside WordPress through api?
- Adding a text element in between title and blocks container
- Block Editor: How to get title and post content within the WordPress admin UI in Javascript?
- Load plugin JS in footer
- Using wp_localize_script inside template page to transfer var from php to js
- How to return div with custom attributes(Coding a Gutenberg Block)
- Problem with JavaScripts addition in WordPress
- Setting a menu link to open a pop-up
- Media library not working with wp_editor() on the front end
- Is there a media_upload_tabs-similar filter to add tabs to the simple/featured image picker?
- Tinymce.js editor in Chrome?
- How to display post content in the block editor
- My Button Default Click Is Not Working In WordPress Using Javascript Code
- WordPress update_user_meta onclick button with Ajax
- Gutenberg RangeControl
- WordPress opens js files as a catalog. Path is right [closed]
- Javascript to open new window
- Add a Page Screen is Visually Blank
- Debugging JS errors
- Javascript File Does Not Work
- Gutenberg sidebar show input field on toggle
- Get the ID of a page in Parent combobox in editor
- Google Page Speed
- Is it feasible to call angular’s page from wordpress website?
- Connecting a wordpress site to an AngularJS APP
- WOW.js Script Tag Initialization Header/Footer
- Making the HTML list to a checkbox tree with the plugin jstree [closed]
- WordPress Gutenberg: Attribute overwritten by block duplicate
- How to delete child block for associated parent block
- Registration fields prefilled with URL parameters
- Divi Carousel/ Slider – How to slide two sliders with a single button
- WordPress adds and tags into HTML blocks after saving
- How do i fix type error
- CCF7 Field numbuer prefilled after Click event
- Access jQuery tabs from primary menu while adding/removing class on tab container elements (accessing diff. tabs/tab content via primary menu items)