/    Sign up×
Community /Pin to ProfileBookmark

asking Elements what tag they have…

Hi everybody, ?

if i use the following code i will get an array with all elements in the document.

[CODE]var elements = document.getElementsByTagName(‘*’);[/CODE]

now i need to know what tags the elements have… But how do i do that?

What i want to accomplish:
1. get all elements
2. ask them if they have a name attribute, if true ignore them
3. ask them if they have an attribute lang, if not ignore them
4. ask them the value of lang
5. ask them what tag they have
6 on the base of lang and the tag display mode is choosen.

I try to build a multilanguage clientside-only website. The parts in different languages are marked with lang attributes. There is one defaut language that is set to visible even without js.
Now i have to search the whole document tree to find the elements with the lang Attribute and get the value. Then i have to know the tag to determine the mode of the display settings: list-item or inline or block, etc.

Hope you can tip me off.

Greets ?

Jens

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@DokOct 04.2007 — element.tagName will reveal the tag name
Copy linkTweet thisAlerts:
@jens1701authorOct 05.2007 — thx dok

was a simple answer was it...

don`t know why i didn't found it yesterday...

cu

Jens
×

Success!

Help @jens1701 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...