I have an chrome extension in which I want to automatically fill in a username and password field with information the user has entered already (into my application) by running external javascript on the page. I figured out how to fill in the username, but I can't figure out how to automatically check a checkbox or fill in the password.
Without jQuery, one can do as follows:
document.getElementById( "password" ).value = "Value";
document.getElementById( "checkbox" ).checked = true;
of course replacing "password"
with the ID of the password input box, and the same with "checkbox"
.
if you're using jQuery you can do this:
$('#password').val('whateveryouwant');
$('#checkbox').attr('checked','checked');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.