I want to extract a user name and password pair and its corresponding form element on a ‘Log in’ page by analyzing Document Object Model (DOM) objects.
First, all the HTMLInputElement objects within the HTMLDocument object of the ‘Log in’ page are to be collected. Next, the password object is located by examining its special attribute type="password".
Answering the body of your question:
You can find elements using
document.getElementsByTagName. E.g.:Use this knowledge only to benefit Humanity, not in an evil quest for global domination. 😉
Answering the title of your question:
You create elements via
document.createElement, e.g.: