document.querySelector("#薪酬")。点击()

时间:2014-03-18 06:40:23

标签: javascript forms click

帮助设置延迟,然后点击您可以编写的选项我真的不明白

<form class="form-for-pay" action="https://merchant.webmoney.ru/lmi/payment.asp?at=authtype_8" method="post" id="paypal_form_submit">
    <input type="hidden" name="LMI_PAYMENT_AMOUNT" value="20" />
    <input type="hidden" name="LMI_PAYMENT_DESC" value="" />
    <input type="hidden" name="LMI_PAYMENT_DESC_BASE64" value="0J/QvtC/0L7Qu9C90LXQvdC40LUg0YHRh9C10YLQsA== " />
    <input type="hidden" name="LMI_PAYEE_PURSE" value="Z000000000000" />
    <input type="hidden" name="id" value="70" />
    <input type="hidden" name="id_user" value="2" />
    <button type="submit" style="display:none;" class="btn btn-success" id="pay">
        Pay
    </button>
</form>
<script type="text/javascript">
document.querySelector("#pay").click()
</script>

1 个答案:

答案 0 :(得分:1)

您应该使用getElementById代替querySelector,因为它要快得多。 getElementById vs. querySelector。如果没有ID,您可以使用querySelector,并且必须使用例如不支持getElementsByClassName&lt; = IE8

window.setTimeout(function () {
    document.getElementById("pay").click()
}, 2000);