I have a disabled button I want to click with Javascript. The following function works in Chrome but not in Firefox.
The problem with Firefox: Firefox javascript is too slow.
The button is still disabled if the code wants to click it. How to click the button when it is enabled?
function enable_and_click() {
document.getElementById('button1').disabled=false;
document.getElementById('button1').click();
}
Try the following:
document.getElementById('button1').removeAttribute('disabled');
document.getElementById('button1').click();
Update
Using jQuery, a cross browser solution would be:
var element = $('#button1');
element.removeAttr('disabled');
element.click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.