Tuesday, 14 October 2014

JavaScript Output

JavaScript Output

JavaScript does not have any print or output functions.
In HTML, JavaScript can only be used to manipulate HTML elements.

Manipulating HTML Elements

To access an HTML element from JavaScript, you can use the document.getElementById(id) method.
Use the id attribute to identify the HTML element, and innerHTML to refer to the element content:
______________________________________________________________________________

Example

<!DOCTYPE html>
<html>
<body>

<h1>My First Web Page</h1>

<p id="demo">My First Paragraph</p>

<script>
document.getElementById("demo").innerHTML = "Paragraph changed.";
</script>

</body>
</html>
_______________________________________________________________________________
The JavaScript statement above (inside the

1 comment: