Does anyone knows, how to all the list of all the elements on the web
page using javascript.
document.getEle mentsByTagName( '*')
should give all elements in the document. Assuming "web page" is an HTML
document and you want the elements in the body then you might only want
to look in the body e.g.
document.body.g etElementsByTag Name('*')
On Oct 3, 12:58 pm, Martin Honnen <mahotr...@yaho o.dewrote:
Sunny wrote:
Does anyone knows, how to all the list of all the elements on the web
page using javascript.
>
document.getEle mentsByTagName( '*')
should give all elements in the document. Assuming "web page" is an HTML
document and you want the elements in the body then you might only want
to look in the body e.g.
document.body.g etElementsByTag Name('*')
>
--
>
Martin Honnen http://JavaScript.FAQTs.com/
When I do:
alert(document. getElementsByTa gName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
As I am creating some elements dynamically, i want the name of all the
elements present on my webpage.
And I want to do that in Firefox.
Any solution.
On Oct 3, 12:58 pm, Martin Honnen <mahotr...@yaho o.dewrote:
>Sunny wrote:
Does anyone knows, how to all the list of all the elements on the web
page using javascript.
>>
> document.getEle mentsByTagName( '*')
>should give all elements in the document. Assuming "web page" is an HTML
>document and you want the elements in the body then you might only want
>to look in the body e.g.
> document.body.g etElementsByTag Name('*')
>>
>--
>>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>
When I do:
alert(document. getElementsByTa gName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
Well, yeah.
var elements = document.getEle mentsByTagName( "*");
for (var i = 0; i < elements.length ; i++) {
alert(elements[i]);
}
Though I would strongly recommend you install firebug, enable it and do:
console.debug(e lements);
When I do:
alert(document. getElementsByTa gName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
As I am creating some elements dynamically, i want the name of all the
elements present on my webpage.
And I want to do that in Firefox.
As you might have gathered from previous replies, you
a) need to do something with the collection
b) it isn’t clear from your description what that would be
If you just want a list of the used element types, you’d want to
avoid duplicates and probably sort the result, e.g.
var list = document.getEle mentsByTagName( '*'),
l = list.length,
result = [],
node;
while (l--) {
node = list[l].nodeName;
if (-1 === result.indexOf( node)) {
result.push(nod e);
}
}
alert(result.so rt());
Comment