DOM- Quick Quiz

1.Which JavaScript method is used to access an HTML element by id?

A) getElementById()
B) getElement(id)
C) getElementById(id)
D) elementById(id)

2.Which property is used to define the HTML content to an HTML element with a specific id?

A) innerText
B) innerContent
C) elementText
D) innerHTML

3.Which JavaScript method is used to write HTML output?

A) document.write()
B) document.output()
C) console.log()
D) document.writeHTML()

4.What is the output of the following JavaScript code?

<script>
	var name = "Alex" + " " + "Alvin";
	document.getElementById("demo").innerHTML = name;
</script>

A) Alex Alvin
B) AlexAlvin
C) TypeError
D) ValueError

5.What is the output of the following JavaScript code?

<script>
	var a = 10 + 20 + "5";
	document.getElementById("demo").innerHTML = a;
</script>

A) 35
B) 305
C) TypeError
D) ValueError

1 Like

A
D
A
A
B

THE ANSs for the above question as such

1 Like
  1. option A
    2.D
    3.A
    4.A
    5.B
1 Like
  1. c
  2. d
  3. a
  4. a
  5. b
1 Like
  1. Option C
  2. Option D
  3. Option A
  4. Option A
  5. Option B
1 Like
  1. C
  2. A
  3. A
    4.Alex Alvin
    5.305
1 Like
  1. A
  2. A
  3. A. document.write()
  4. A
    5.B. 305
1 Like