我正在尝试完成一个填写结帐表格的脚本。它需要单击一个没有 ID 或名称的按钮,然后填写出现的表单的其余部分。我必须单击按钮的代码是:
document.querySelector('input[type="submit"][value="continue"]').click();
Run Code Online (Sandbox Code Playgroud)
但这对我不起作用,其他元素将出现在我的脚本之后:
// ==UserScript==
// @name Script
// @include https://checkout.bigcartel.com/*
// @include http://*.bigcartel.com/product
// @include http://*.bigcartel.com/cart
// @grant none
// ==/UserScript==
// on "/cart" page click checkout button
if (window.location.origin !== "https://checkout.bigcartel.com") document.getElementsByName("checkout")[0].click();
else {
// fill first three form fields
document.getElementById("buyer_first_name").value = "John";
document.getElementById("buyer_last_name").value = "Smith";
document.getElementById("buyer_email").value = "john@doe.com";
//click button for next section
document.querySelector('input[type="submit"][value="continue"]').click();
}
Run Code Online (Sandbox Code Playgroud) 我正在使用引导程序作为登录页面,我见过人们在引导程序中使用没有“href”的标签,但它对我不起作用,有什么想法吗?
我只是在完成之前尝试一个简单的警报自动取款机,当我可以正常工作时,我将在登录和注册页面之间切换链接。目前它只显示为纯文本。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Secret Diary</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<section id="login">
<div class="container">
<div class="center">
<div class="col-md-12 mx-auto">
<h1>Secret Diary</h1>
<h2>Store you thoughts</h2>
<div class="error"><?php echo $error; ?></div>
<form method="post" id="signupForm">
<input type="email" class="form-control" name="email" id="email" placeholder="email">
<input type="password" class="form-control" name="password" id="password" placeholder="password">
<div class="checkbox">
<label>
<input type="checkbox" name="stayLoggedIn" value="1"> Stay Logged In
</label>
</div>
<input type="hidden" name="signUp" value="1">
<input …Run Code Online (Sandbox Code Playgroud)