尝试编写一个脚本来自动点击评级页面上的按钮。脚本适用于单个元素,但不适用于整个页面
Trying to write a script that auto-clicks the buttons on a rating page. Script works for one single element but not the whole page
我只想单击页面上的 + 按钮,并使它们在每 table 行(24 列和 100 行)中增加到 4。
这些按钮只有在您单击每个扇区时才会出现。
Complete Row
这就是您点击它时的样子。
Picture of the button (+ button)
这是我标记的代码片段。
Code Snippet
我使用了不同的脚本,比如这个:
<!DOCTYPE html>
<html>
<body>
<p>Hover over the checkbox to simulate a mouse-click.</p>
<form>
<input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('click event occured')">
</form>
<script>
function myFunction() {
document.getElementById("myCheck").click();
}
</script>
</body>
</html>
并尝试在逻辑点插入它,但它只适用于一个 table 元素。
我希望脚本适用于所有 + 按钮。
您可以 select 所有带有 class skilllevel_inc
的按钮,然后在每个按钮上单击 4 次。示例代码为:
let allButtons = document.getElementsByClassName("skilllevel_inc");
for(var i=0 ; i<allButtons.length ; i++) {
if(allButtons[i]) {
let j=0;
while(j<4) {
allButtons[i].click();
j+=1;
}
}
}
我只想单击页面上的 + 按钮,并使它们在每 table 行(24 列和 100 行)中增加到 4。 这些按钮只有在您单击每个扇区时才会出现。 Complete Row
这就是您点击它时的样子。 Picture of the button (+ button)
这是我标记的代码片段。 Code Snippet
我使用了不同的脚本,比如这个:
<!DOCTYPE html>
<html>
<body>
<p>Hover over the checkbox to simulate a mouse-click.</p>
<form>
<input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('click event occured')">
</form>
<script>
function myFunction() {
document.getElementById("myCheck").click();
}
</script>
</body>
</html>
并尝试在逻辑点插入它,但它只适用于一个 table 元素。 我希望脚本适用于所有 + 按钮。
您可以 select 所有带有 class skilllevel_inc
的按钮,然后在每个按钮上单击 4 次。示例代码为:
let allButtons = document.getElementsByClassName("skilllevel_inc");
for(var i=0 ; i<allButtons.length ; i++) {
if(allButtons[i]) {
let j=0;
while(j<4) {
allButtons[i].click();
j+=1;
}
}
}