Javascript Flashcards
- HTML to define the _______
- CSS to specify the _______
- JavaScript to program the _______
- content of web pages
- layout of web pages
- behavior of web pages
Javascript Syntax:
p id=”demo”
<script> document.getElementById("demo").innerHTML = "My First JavaScript"; </script>
p id=”_____”
button type=”button” _______=”myFunction()”
<_____>
function _____() {
document.getElementById(“demo”)._________= “Paragraph changed.”;
}
</_____>
p id=”demo”
button type=”button” onclick=”myFunction()”
<script> function myFunction() { document.getElementById("demo").innerHTML = "Paragraph changed."; } </script>
External JavaScript:
Scripts can also be placed in external files:
script src=”myScript.js” script
To access an HTML element, JavaScript can use the __________ method.
document.getElementById(id)
The innerHTML property defines the ___________
HTML content
window.alert() use:
You can use an alert box to display data.
You can skip the window keyword. It is Optional.
alert()
For debugging purposes, you can call the __________ method in the browser to display data.
console.log()
How to print the content of the current window in javascript?
button onclick=”window.print()”
JavaScript uses the keywords ________ to declare variables.
var, let and const
let x;
x = 6;
Code after double slashes ___ or between________ is treated as a comment.
//
/* and */
__________ are not allowed in JavaScript. They are reserved for subtractions.
Hyphens
‘Let’ keywords cannot be _____
Redeclared
Variables defined with ___ can be redeclared.
var
javascript variable declaration syntax:
p id=”demo”> /p
script
let person = “John Doe”, carName = “Volvo”, price = 200;
document.getElementById(“demo”).innerHTML = carName;
/script