Question: JavaScript Questions Question 11 Which of the following tags will correctly reference JavaScript code in a file named myfile.js , if it is in a

JavaScript Questions

Question 11

Which of the following tags will correctly reference JavaScript code in a file named myfile.js, if it is in a subdirectory named scripts?

Question 11 options:

Question 12

Which is the proper syntax to locate a div with an ID of "myElement" and assign it to a variable named myVariable that has not been created before?

Question 12 options:

var myVariable=document.innerHTML("myElement");

myVariable=document.innerHTML("myElement");

var myVariable=document.getElementById("myElement");

myVariable=document.getElementById("myElement");

Question 13

You have already written code to locate a div on the page, and you assigned it to a variable named myVariable. What is the proper syntax to change the text in the div?

Question 13 options:

myVariable.innerHTML="New Text";

myVariable.getElementById="New Text";

document.getElementById(myVariable);

document.innerHTML(myVariable);

Question 14

In order to create a block of text that you can reference using getElementById and innerHTML, you need to add an ID to:

Question 14 options:

a

tag

a tag

an

tag

any html opening tag

Question 15

True or False: Like other JavaScript statements, it is important to always put a semicolon after a line that starts with function(...)

Question 15 options:

True

False

Question 16

What will happen when you run the following code:

function doSomething() { alert("hi there"); }

doSomething();

Question 16 options:

doSomething will appear on the screen in an alert box

hi there will appear on the screen in an alert box

You will see an error message, because the code is not correct

Nothing will display on the screen, because the code does not call a function correctly

Question 17

Which is the correct syntax for an alert box which displays "Have a great day!" ?

Question 17 options:

document.alert("Have a great day!");

dom.alert("Have a great day!");

alert("Have a great day!");

console.log("Have a great day!");

Question 18

In the expression

document.write("this is another message!");

write is a(n):

Question 18 options:

object

property

method

function

event

variable

Question 19

What will be the effect of the following JavaScript code, when it is inserted into a web page inside of a script block?

var newElement = document.createElement("hr"); document.body.appendChild(newElement);

Question 19 options:

It will modify the HTML file, adding an hr tag.

It will add an hr tag in memory, which will display a line on the page but not alter the HTML in the file.

It will have no effect, because there is an error in this code.

It will display an error message, because there is an error in this code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!