JavaScript Introduction
JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML and CSS) we have covered in much more detail in other parts of the Learning Area.
JavaScript Can Change HTML Content
One of many JavaScript HTML methods is getElementById()
.
The example below "finds" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":
Example:
document.getElementById("demo").innerHTML = "Hello JavaScript";
JavaScript Can Change HTML Styles (CSS)
Changing the style of an HTML element, is a variant of changing an HTML attribute:
document.getElementById("demo").style.fontSize = "35px";
JavaScript Can Hide HTML Elements
Hiding HTML elements can be done by changing the display
style:
document.getElementById("demo").style.display = "none";
JavaScript Can show HTML Elements
document.getElementById("demo").style.display = "block";
0 মন্তব্যসমূহ