/    Sign up×
Community /Pin to ProfileBookmark

document.getElementById(‘ID’);

is it possible to do something like this?

var blah = document.getElementById(‘a1’) && document.getElementById(‘a2’);

im assuming no because the script will read the second document.getElementByID right?

is there another way to go about doing this?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@crushmeguyOct 03.2006 — What exactly do you want to happen? Do you want blah to be the returned objects or do you want blah to be 'true' if both elements exist?

Regardless, neither of these happen.

Doug
Copy linkTweet thisAlerts:
@Rossario123authorOct 03.2006 — i wan't var blah to be returned objects

so that i can preceed with

var blah = document.getElementById('a1') && document.getElementById('a2');

var whatever = blah.getElementsByTagName('img');

but i guess this will not work.

and so it will not work

what would be the other way around?
Copy linkTweet thisAlerts:
@CharlesOct 03.2006 — var blah = document.getElementById('a1') && document.getElementById('a2');With a && operator the left operand is evaluated. If it evaluates to false then it is returned. If it evaluates to true than the right side is returned.alert (false && 'foo') // alerts 'false'var blah = document.getElementById('a1') || document.getElementById('a2');However the || operator returns the first operand if true but the second if it is false.

I'm thinking that you want "||", that you want a2 if a1 is not found. But the question is, What on Earth are you trying to accomplish?
Copy linkTweet thisAlerts:
@Rossario123authorOct 03.2006 — im trying to get a onmouseover script to work on both ID's.
Copy linkTweet thisAlerts:
@CharlesOct 03.2006 — Well you're no going to get it to work that way. Treat each one as an individual.
Copy linkTweet thisAlerts:
@Rossario123authorOct 03.2006 — but im not familare with using DOM on scripting

if you could help me along that would be great

or point me in the right direction.

here is the .js file

http://www.rx2-designs.com/js/enter.js

im having difficulties trying to get another id of no_flash into the equation..
Copy linkTweet thisAlerts:
@Rossario123authorOct 04.2006 — any help would be appreciated
×

Success!

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