简体   繁体   English

使用javascript“点击”没有ID的提交按钮

[英]"clicking" submit button with no ID using javascript

Here is the submit button i would like to 'click' using javascript.这是我想使用javascript“单击”的提交按钮。

<input type="submit" name="REG_BTN" value="Submit Changes">

I am trying to use something along the lines of...我正在尝试使用...

document.getElementsByTagName('submit')[0].click();

to 'click' the button, but it does not work. “单击”按钮,但它不起作用。 I am writing a script to run in browsers so i do not have the ability to change any of the aspects of the submit button.我正在编写一个脚本以在浏览器中运行,因此我无法更改提交按钮的任何方面。 I am new to javascript so it may just be something simple that i am not picking up.我是 javascript 新手,所以它可能只是一些我没有接受的简单事情。 Is there another way to achieve this?有没有另一种方法来实现这一目标?

The tagName for that element is INPUT ;该元素的tagNameINPUT there are no elements with tag name submit .没有标签名称submit元素。 Try this:尝试这个:

document.getElementsByName('REG_BTN')[0].click();

If page is complete loading first, and use querySelector (CSS) and click.如果页面先加载完成,则使用 querySelector (CSS) 并单击。

' '

if (document.readyState=='complete'){
  document.querySelector('input[type*="submit"]').click();
}

' '

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM