Kratos Kratos - 1 month ago 13
jQuery Question

Greasemonkey/Tampermonkey Automatically clicking hidden value with submit value?

There are four hidden values with same input clicks which go like this (below), basically I'm trying to only click a specific one I tried using trigger click jquery but that keeps submitting the first value

<form action="" method="post">
<input type="hidden" name="ball" value="op1">
<input type="submit" name="action" value="Throw!">
</form>

<form action="" method="post">
<input type="hidden" name="ball" value="op2">
<input type="submit" name="action" value="Throw!">
</form>

<form action="" method="post">
<input type="hidden" name="ball" value="op3">
<input type="submit" name="action" value="Throw!">
</form>

<form action="" method="post">
<input type="hidden" name="ball" value="op4">
<input type="submit" name="action" value="Throw!">
</form>


I want to click the third one how can I achieve this with JS/jQuery via using Greasemonkey/Tampermonkey?

This is the current code

$("input[value='Throw!']").click();


However this always clicks the last one value "op4"

MJH MJH
Answer

Try this:

$('form').eq(2).find('input[type="submit"]').click();
Comments