NEW
Font size
WorksheetsJavaScripting
Total questions: 10
Worksheet time: 2mins
What is the correct syntax for referring to an external script “index.js” ?
<script name=”index.js”>
<script href=”index.js”>
<noscript src=”index.js”>
<script src=”index.js”>
Which of the following is not a keyword used to define a variable in ES6?
var
val
const
let
Which of the following lines of code can remove the class “nav” from the following element:
<div><div class=”nav”>Hello</div></div>
document.getElementByClass(“nav”).classList.remove(“nav”)
document.getElementById(“div”).removeClass(“nav”)
document.querySelectorAll(“div”).classList.remove(“nav”)
document.querySelector(“div”).removeClass(“nav”)
Which of the following is not valid when creating a function in JavaScript ?
function ( ) => { }
function functionName( ) = { }
function functionName( ) { }
const myFunction = functionName( ) { }
How can one get an attribute “attr” of an element <foo> ?
foo.attributes[0]
foo.attr
foo.attributes.attr
None of the above
How will you return an element with id=”first” ?
document.getElementById(“first”)
document.querySelector(“#first”)
document.querySelector(“.first”)
A and B both
A and C both
How will you change the content inside an element <foo> to the text “Hello World” ?
foo.innerHTML = “Hello World”
foo.innerContent = “Hello World”
foo.innerText = “Hello World”
A and C both
B and C both
Which of the following allows you to call a function based on an elapsed time ?
setElapsedTime( )
setInterval( )
setTimeout( )
setCountDown( )
Which event occurs when the user clicks on an HTML element using a mouse ?
onMouseOver
onChange
onClick
onMouseClick
Which of the following is opposite to an onMouseOver event ?
onMouseOff
onMouseOut
onMouseUnder
None of the above
