I have a website that changes his inputs ids, and I'm trying to make a semi auto-login, filling automatically the email and the password part...
I'm doing this with greasemonkey and jQuery...
I'm trying something like this
$("input[@type=text]").setValue("email@gmail.com");
but h开发者_如何学Pythonad no success... The Page has only the login part, two text type inputs...
What am I missing here?
jQuery changed it's selectors (to match CSS3 selectors, find all selectors here). Try
$("input[type=text]").val("email@gmail.com");
There is no setValue()
method. Use val()
. Assuming:
<input type="text" id="email" name="email">
use:
$("#email").val("email@gmail.com"); // ID selector
If it doesn't have an ID:
$("input[name=email]").val("email@gmail.com");
But favour IDs over attribute selectors where possible.
The problem with:
$("input[type='text']").val("...");
is that it will assign a value to only the first text input on the form. If that's the right one, I guess that's fine. But if you're filling in multiple different inputs you need a different selector.
精彩评论