Grade8 JavaScript
Grade8 JavaScript
5 JavaScript in HTML
Ans- 1. Document.getElementById()
2. document.getElementByClassName()
Ans- JavaScripts are popularly used for creating interactive and Dynamic web pages and web
applications.
Ans-
Ans-External JavaScripts allow users to organize the scripts properly, reuse the script we created and
maintain it more easily.
Ans-
Ans- Karan should use the getElementById() or getElementsByClassName() DOM methods to
highlight specific items in a different colour.
Karan can select specific item from the list by getElement ById or ByName easily.
Ans-
<html>
<head>
<title>
Area of Rectangle</title>
<body>
<script>
Function AreaOfRectangle(length,bredth)
{
var result=2*length*bredth;
alert(“area of a rectangle is:”+result);
}
Var input1=prompt(“enter length of a rectangle:”);
Var input2=prompt(“enter the bredth of a rectangle:”);
Var length=parseInt(input1);
Var bredth=parseInt(input2);
AreaOfRectangle(length,bredth);
</script>
</body>
</html>