*Intro *
- one of many js HTML methods is
.getElementById().
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>
</body>
</html>
On the above code while clicking the button the content will be changed _
Js accepts both double an single Quetes
Js can change the attribute value ex(it can change the value of src (source) attributre of an image )
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>
<img id="myImage" src="pic_bulboff.gif" style="width:100px">
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>
Js can change the css style of an element
Js can hide and show hidding element in HTML
WRITTEN BY OR IN
In HTML javascript Code is inserted Between and tags
You can place any number of scripts in an HTML documnt.
SCripit can be placed in the body ,or in the head section of an html.or in both
Variables and datatypes
Variables ans date types in javaScript are fundatmental concepts used to store and manage data in aa program
variables - Declared using var ,let and const to store data values
1.var- this can be declared and can be reassumed
2.let - this can be declared and can't be reassumed but can be updated
3.const - this can be declared can't be changed

Top comments (0)