Reputation: 726
I am working on a Chrome extension that finds top few font sizes on a page. In order to do so, I need to get all of the text related elements from the page. How can I pull any text related element from the HTML page using JavaScript?
Upvotes: 0
Views: 613
Reputation: 1840
Fairly simple. Use the following code.
textInputs = [];
var fields = document.getElementsByTagName("input"),
_length = fields.length,
input;
for(var i = 0; i < _length; i++){
input = fields[i];
if (!input.type || input.type === 'text'){
textInputs.push(input);
}
}
Upvotes: 1