Consider this source code:

Giam needs to write a script to access the first element in the source code. What code should he use?
Suggested Answer: C
Get Premium 1D0-735 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
40 comments · newest first
JU
Julianna
10 months ago
D has a typo, should be getElementsByTagName, not getElementByIdTagName!
BR
Brendan
11 months ago
Wait, is it really [0] for the first element? Seems off.
GR
Gregoria
11 months ago
Nah, C is definitely the way to go.
AN
Annita
11 months ago
I think B is better, it directly gets the element.
EL
Elvis
11 months ago
Option C is the correct choice!
AN
Angelyn
12 months ago
I’m leaning towards D because it uses getElementByIdTagName, but I can't recall if that's even a valid method.
AL
Alishia
12 months ago
I’m a bit confused about the index numbers. I thought arrays start at 0, so C seems right, but what about A?
AL
Alfreda
12 months ago
I remember practicing a similar question where we had to access elements by their IDs. I feel like B could be a contender too.
JA
Jame
1 year ago
I think the answer might be C, but I'm not entirely sure if it's the right index for the first element.
ST
Stefania
1 year ago
I'm feeling confident about this one. The key is to use the correct DOM selection method, which in this case is `document.getElementById()`. Option C looks like the correct answer.
SH
Sharmaine
1 year ago
Wait, I'm confused. The question says to access the "first element", but the options mention different element IDs. I'll need to re-read the question and think this through step-by-step.
LA
Lacey
1 year ago
Okay, I think I've got this. Based on the image, the first element is the "condiments" element, so option C looks like the right choice.
ER
Eric
1 year ago
Hmm, I'm a bit unsure about this one. The code snippet doesn't seem to match the options provided. I'll need to double-check my understanding of DOM selection methods.
AL
Aleisha
1 year ago
This looks like a straightforward DOM manipulation question. I'll carefully review the code snippet and options to determine the correct way to access the first element.
MA
Marguerita
1 year ago
Okay, let's see. The DMP needs to inform the downstream routers about the merged detour tunnels. I'm not sure if it's sending individual PATH messages or a single message with the merged info.
YU
Yuonne
2 years ago
Hold up, guys. Shouldn't we be using 'document.querySelector' instead of all this 'getElementById' and 'getElementsByTagName' nonsense? That's the modern way to do it, you know.
BR
Brandon
2 years ago
C) var first = document.querySelector('#condiments');
BA
Barney
2 years ago
B) var first = document.querySelector('#input');
AN
Annita
2 years ago
A) var first = document.querySelector('#condiments1');
FI
Fidelia
2 years ago
Okay, let me get this straight. We need to access the first element, not the second one. So option A is just plain wrong. C is clearly the correct answer here.
BR
Brice
2 years ago
I agree, option C is the way to go to access the first element.
AN
An
2 years ago
Yeah, option A is definitely wrong because it's trying to access the second element.
RO
Roslyn
2 years ago
I think you're right, option C is the correct answer.
PA
Patti
2 years ago
Hmm, I'm a bit confused. Shouldn't we be using the 'getElementsByTagName' method instead of 'getElementById'? I think option D is the way to go.
ET
Ettie
2 years ago
User1: Maybe we should reconsider our options.
CH
Chaya
2 years ago
User3: I agree with User2, option D seems incorrect.
GE
German
2 years ago
But wouldn't we use getElementsByTagName instead of getElementById?
CH
Chaya
2 years ago
I think option D is correct.
GE
Gearldine
2 years ago
Option B looks good to me. Accessing the element with the ID 'input' should give us the first input element in the source code.
TH
Thora
2 years ago
Let's go with option B then. It seems like the most logical choice.
CH
Chaya
2 years ago
I agree, using document.getElementById('input') should work.
VI
Vinnie
2 years ago
I think option B is correct. It should access the first input element.
MI
Miss
2 years ago
I'm pretty sure the correct answer is C. The code needs to access the first element with the ID 'condiments', and that's exactly what the option C code does.
QU
Quiana
2 years ago
Yes, option C is the right choice to access the first element with the ID 'condiments'.
AR
Ariel
2 years ago
That makes sense, option C is using the correct method to access the first element.
GW
Gwen
2 years ago
I agree, option C is accessing the element with the ID 'condiments' at index 0.
LA
Latricia
2 years ago
I think you're right, option C looks like the correct code to access the first element.
PR
Providencia
2 years ago
Why do you think it's A?
BE
Bea
2 years ago
I disagree, I believe the answer is A.
PR
Providencia
2 years ago
I think the answer is C.