/    Sign up×
Community /Pin to ProfileBookmark

Change the color of links

I have this application that changes the color of the text in a div by just changing the style. The code is really simple but my problem is that I never know if there is a link inside the div or not since you can change the contents of the div at will. I am looking for a way to get to the links inside the div whether there or not.

Thanks the for the help

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@BuilderQOct 20.2006 — [code=php]document.getElementById('div_id').getElementsByTagName('a').length[/code] will return the number of links within the given div. The first link can be accessed with [code=php]document.getElementById('div_id').getElementsByTagName('a')[0][/code], the second with [code=php]document.getElementById('div_id').getElementsByTagName('a')[1][/code], and so on.
Copy linkTweet thisAlerts:
@thechasboiauthorOct 20.2006 — BuilderQ

That looks excellent. I have seen something similar but never used it. I will try tomorrow or tonight and reply my results. Thaks a ton. Much appreciated.
Copy linkTweet thisAlerts:
@thechasboiauthorOct 29.2006 — BuilderQ

Tried your suggesion and it worked like a charm. Thanks a ton for the suggestion and sorry for the delay. Had some othert things come up in the mean time.
×

Success!

Help @thechasboi 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.17,
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,
)...