Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOM click() is not working on this button

When I use method click() to click the button, the submission failed.
But, when I use the mouse to click the button on that webpage, (the submit form is same) it works.

HTML file:

<button xmlns="http://www.w3.org/1999/xhtml" class="ui-button button1"       type="submit" id="create">
    <span>
        <span>Create</span>
    </span>
</button>

My userscript file:

document.getElementById("create").click();

How do I click the button using HTML DOM click()?

like image 375
CodeCat Avatar asked Jan 18 '26 21:01

CodeCat


1 Answers

maybe instead of clicking the button. You can submit the form in javascript as

document.getElementByName('form1').submit();

as it fulfills your requirement.

like image 50
Ashish Chopra Avatar answered Jan 20 '26 10:01

Ashish Chopra