Inside which HTML element do we put theJavaScript? javascript script scripting What is the correct JavaScript syntax
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 below?
This is a demonstration.
document.getElement(“p”).innerHTML= “HelloWorld!;
document.getElementByName("p").innerHTML = "HelloWorld!";
#demo.innerHTML = "Hello World!";
document.getElementById("demo").innerHTML = "HelloWorld!";
How do you create a function in JavaScript?
function:myFunction()
function myFunction()
function void myFunction()
function = myFunction()
What is the correct way to write a JavaScriptarray?
var colors = "red", "green", "blue"
var colors = ["red", "green", "blue"]
var colors = 1 = ("red"), 2 = ("green"), 3 =("blue")
var colors = (1:"red", 2:"green",3:"blue")
Which event occurs when the user clicks on an HTMLelement?
onmouseover
onchange
onclick
onmouseclick
How do you declare a JavaScript variable?
variable carName;
v carName;
var carName;
$carName;
What will the following code return: Boolean(10 >9)
NaN
False
True
Null
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:
4
3
2
1
Based upon the previous question, how many children doesthe paragraph have?
1
2
3
4
Which event do we use to ensure the HTML page has loadedbefore attaching event handlers?
browser.onload
window.onload
browser.onLoad
window.onLoad
What is the difference between == and === inJavascript
=== is not a valid operator in Javascript
They are both the same operator
== Tests Equality of only value, === tests equality ofonly type
== Tests Equality of value, === tests equality of bothtype and value
Which of the following values are considered true injavascript:
Undefined
Null
“False”
parseInt(0.97)
What is the difference between Null and Defined inJavascript
Null is a declaration value, Undefined isnot
Undefined is a declaration value, null isnot.
They have different truth values
There are no differences between the 2, only Conventionof use
Which of the following returns a unique HTML elementfrom the DOM
getElementByTagName(tag)
getElementByName(name)
getElementById(id)
getElementsByName(name)
Which of the following is not a DOM manipulationmethod:
appendChild(node)
insertAfter(new, old)
insertBefore(new, old)
replaceChild(new, old)
Part 2:
Short Answer (8pts each)
(all questions using base javascript - NOJQUERY/PROTOTYPE)
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).
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.
What is the dom? What type of structure does it use?What do we use it for in Javascript?
Write some js code that would change all the paragraphelements that are inside of an element with the id alert to havered text.
Write js to do the following:
Create a new h2 element
Set its text to read “This is a heading”
Set the color of the background to blue
Add the dom object you created to the id“menu”.
Write some js code that would remove all li elementswith the text “batman” from the dom.
Write javascript and html code that will do thefollowing.
Make a header that says “The AmazingAdder”
Create a div
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.
Create a span called answer after the equals signfollowed by a line break.
Make a button inside the div as well and attach ajavascript function to it.
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.
Advanced Accounting
ISBN: 978-0077431808
10th edition
Authors: Joe Hoyle, Thomas Schaefer, Timothy Doupnik