Get the input type of a textbox

14,251

The type of the input is a property on the element.

For example, you can open chrome inspector on this page and type in the console:

var firstInput = document.getElementsByTagName('input')[0];
firstInput.type; // outputs "text"

edit: you could bind the click on these elements and get the type from the event.target property of the event.

Share:
14,251
user782400
Author by

user782400

Updated on June 04, 2022

Comments

  • user782400
    user782400 almost 2 years

    I am making a chrome extension for which I am trying to listen to the mouse clicks using message passing.

    I want to know if it is possible to obtain the input type of a textbox when a mouse ic clicked on the textbox ?