0% found this document useful (0 votes)
5 views

Java Script Codes Grade 12 Bi

Uploaded by

Wilson Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Java Script Codes Grade 12 Bi

Uploaded by

Wilson Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

(ICT)

Java Script Codes


Grade 12
(2024-2025)

2024-2025 ICT Page 1 of 3


document.write(“hello”) Generate content or text on a web
page
Example: <script>

document.write(“hello”)
</script>

document.getElementByld is used to target an HTML element by


its ID
.innerHTML text within the element

Example: <html>
<body>
<p ID = “Paragraph1” > </p>
<script>
document.getElementByld (“Paragraph1”).innerHTML “hello world”
</script>
</body>
</html>

alert(“hello world”) A notification message to the user.

var answer = confirm (“ ok to next step”) A confirm box has two options: ok and
cancel
var result = prompt (“ What is your name ?”) A prompt box will allow the user to
enter some text and give them the
option of ok and cancel
console.log (“ alert”) It helps to track the flow of their code
and identify issues, its for debugging
<img src ="" id ="img1"> The <img> tag in HTML adds an
image to a web page.
The src attribute tells the browser
where to find the image,
and the id attribute gives the image a
unique name so you can style or
control it with JavaScript.
Example:
<html>
<body>
<img src ="" id ="img1">
<script>
document.getElementById("img1").src = " 6.JPEG"
</script>
</body>
</html>

2024-2025 ICT Page 2 of 3


document.getElementById("img1").height = "500 " To change the height of the image

document.getElementById("img1").width = "500 " To change the height of the image

document.getElementById ("p1") .style.color = "blue" To change the color of the paragraph

document.getElementById ("p1") .style .fontSize = "x-large" To change the font size of the
paragraph
document.getElementById ("p1") .style .fontFamily = "Arial" To change the font family of the
paragraph (Arila , Calibri)
document.getElementById ("p1") .style .fontWeight = "bold" To change the font weight of the
paragraph (Bold ,lighter, normal)
document.getElementById ("p1") .style.backgroundColor = To change the paragraph background
"yellow” color
Example:

<html>
<body>
<p id = "p1" > This is my first paragraph </p>
<p id = "p2" > This is my second paragraph</p>
<script>
document.getElementById ("p1") . style .color = "blue"
document.getElementById ("p1") . style .fontSize = "x-large"
document.getElementById ("p1") . style .fontFamily = "Arial"
document.getElementById ("p1") . style .fontWeight = "bold"
document.getElementById ("p1") .style.backgroundColor = "yellow"
document.getElementById ("p2") . style .color = "green"

</script>
</body>
</html>

2024-2025 ICT Page 3 of 3

You might also like