GoConqr has a new look! Let us know what you think.

Module 3 of 21 · Media

Selecting Elements

Kostas Diakogiannis

Selecting Elements

Selecting DOM elements

Generally speaking there are many different ways to select elements from an HTML document. We use these functions:

document.body  // returns the whole body element of the html document

document.getElementById('unique') // returns the element with the id set to 'unique'

document.getElementsByTagName('H3') // returns an array with all h3 elements

document.getElementsByClassName('bigSize')  // returns an array with this class elements

document.querySelector('p.intro') // CSS selector type. Returns the first element that is a p and has a class 'intro'

document.querySelectorAll('div img') // returns an array with images that lie inside a div

 

Find a full list here!

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?