Search Header Logo

JavaScript and CSS Basics Quiz

Authored by R Eveleigh

Computers

9th Grade

Used 3+ times

JavaScript and CSS Basics Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct way to define a function in JavaScript?

function = myFunction() {}

function myFunction() {}

def myFunction() {}

function: myFunction() {}

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the `getElementById` method do in JavaScript?

It selects all elements with a specific class name.

It selects the first element with a specific tag name.

It selects the element with a specific id.

It creates a new element with a given id.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you change the content of an HTML element with the id "demo" to "Hello, World!" using JavaScript?

document.getElementById("demo").innerHTML = "Hello, World!";

document.getElementById("demo").value = "Hello, World!";

document.getElementById("demo").text = "Hello, World!";

document.getElementById("demo").content = "Hello, World!";

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which symbol is used to select a class in CSS?

#

.

$

@

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you select an element with the id "main" in CSS?

.main

#main

main

*main

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to add a click event handler to a button with the id "myBtn" in JavaScript?

document.getElementById("myBtn").onclick = myFunction;

document.getElementById("myBtn").onClick(myFunction);

document.getElementById("myBtn").addEvent("click", myFunction);

document.getElementById("myBtn").click = myFunction();

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax to select all elements with the class "highlight" in CSS?

#highlight

.highlight

highlight

*highlight

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?