Clicking submit button of an HTML form by a Javascript code

后端 未结 3 1845
野趣味
野趣味 2021-02-07 04:33

I don\'t know much about WEB probramming, so feel free to ask if I\'m missing any details.

There is a certain website which I\'m visiting very frequently, and it require

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 05:24

    The usual way to submit a form in general is to call submit() on the form itself, as described in krtek's answer.

    However, if you need to actually click a submit button for some reason (your code depends on the submit button's name/value being posted or something), you can click on the submit button itself like this:

    document.getElementById('loginSubmit').click();
    

提交回复
热议问题