Question: Inside which HTML element do we put theJavaScript? javascript script scripting What is the correct JavaScript syntax to change the content of the HTML element

  1. Inside which HTML element do we put theJavaScript?

    1. javascript

    2. script

    3. scripting


  2. What is the correct JavaScript syntax to change the content of the HTML element below?

    This is a demonstration.


    1. document.getElement(“p”).innerHTML= “HelloWorld!;

    2. document.getElementByName("p").innerHTML = "HelloWorld!";

    3. #demo.innerHTML = "Hello World!";

    4. document.getElementById("demo").innerHTML = "HelloWorld!";

  3. How do you create a function in JavaScript?

    1. function:myFunction()

    2. function myFunction()

    3. function void myFunction()

    4. function = myFunction()

  4. What is the correct way to write a JavaScriptarray?

    1. var colors = "red", "green", "blue"

    2. var colors = ["red", "green", "blue"]

    3. var colors = 1 = ("red"), 2 = ("green"), 3 =("blue")

    4. var colors = (1:"red", 2:"green",3:"blue")

  5. Which event occurs when the user clicks on an HTMLelement?

    1. onmouseover

    2. onchange

    3. onclick

    4. onmouseclick

  6. How do you declare a JavaScript variable?

    1. variable carName;

    2. v carName;

    3. var carName;

    4. $carName;



  1. What will the following code return: Boolean(10 >9)

    1. NaN

    2. False

    3. True

    4. Null

  2. How many child nodes does the following div have:

This is a paragraph of text witha

link.

How many children(child nodes) does thefollowing div have:

    1. 4

    2. 3

    3. 2

    4. 1

  1. Based upon the previous question, how many children doesthe paragraph have?

    1. 1

    2. 2

    3. 3

    4. 4

  2. Which event do we use to ensure the HTML page has loadedbefore attaching event handlers?

    1. browser.onload

    2. window.onload

    3. browser.onLoad

    4. window.onLoad

  3. What is the difference between == and === inJavascript

    1. === is not a valid operator in Javascript

    2. They are both the same operator

    3. == Tests Equality of only value, === tests equality ofonly type

    4. == Tests Equality of value, === tests equality of bothtype and value

  4. Which of the following values are considered true injavascript:

    1. Undefined

    2. Null

    3. “False”

    4. parseInt(0.97)

  5. What is the difference between Null and Defined inJavascript

    1. Null is a declaration value, Undefined isnot

    2. Undefined is a declaration value, null isnot.

    3. They have different truth values

    4. There are no differences between the 2, only Conventionof use

  6. Which of the following returns a unique HTML elementfrom the DOM

    1. getElementByTagName(tag)

    2. getElementByName(name)

    3. getElementById(id)

    4. getElementsByName(name)

  7. Which of the following is not a DOM manipulationmethod:

    1. appendChild(node)

    2. insertAfter(new, old)

    3. insertBefore(new, old)

    4. replaceChild(new, old)


Part 2:

Short Answer (8pts each)

(all questions using base javascript - NOJQUERY/PROTOTYPE)

  1. What is unobtrusive javascript? What does it entaildoing conceptually?What steps do we do to turn our obtrusivejavascript calls into unobtrusive ones(how do we change thecode).

  2. What is an anonymous function?When do we use it? Write ashort example of one that runs when the dom is finished loading andwill attach a function called myclick() to a button with id ofmybutton.

  3. What is the dom? What type of structure does it use?What do we use it for in Javascript?

  4. Write some js code that would change all the paragraphelements that are inside of an element with the id alert to havered text.

  5. Write js to do the following:

    1. Create a new h2 element

    2. Set its text to read “This is a heading”

    3. Set the color of the background to blue

    4. Add the dom object you created to the id“menu”.

  6. Write some js code that would remove all li elementswith the text “batman” from the dom.

  7. Write javascript and html code that will do thefollowing.

    1. Make a header that says “The AmazingAdder”

    2. Create a div

    3. Inside the div place 2 input fields, num1 and num2. Typewill be text and size will be 3. Between them will be a + sign andafter them will display an = sign.

    4. Create a span called answer after the equals signfollowed by a line break.

    5. Make a button inside the div as well and attach ajavascript function to it.

    6. Create a javascript function within script tags (you donot need a seperate file) that will grab the input from num1 andnum2. Save their sum into a variable and update the html on thepage so that their sum shows up in the answerspan.



Step by Step Solution

3.55 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Inside which HTML element do we put the JavaScript script 2 What is the correct JavaScript syntax to change the content of the HTML element below do... View full answer

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 Programming Questions!