JavaScript is used to create client-side dynamic pages. JavaScript is easy to learn. JavaScript is an object-based scripting language which is lightweight and cross-platform.
JavaScript (js) is a lightweight object-oriented programming language that is used to script webpages on many websites. When used with an HTML document, it is an interpreted, complete programming language that enables dynamic interactivity on websites. It was first released in 1995 to allow users of the Netscape Navigator browser to add programs to webpages. Since then, every other graphical web browser has integrated it. Users can create interactive modern web applications with JavaScript without continually refreshing the page. The conventional website makes use of js to offer various forms of simplicity and interactivity.
However, JavaScript has no connection with the Java programming language. The name was suggested and offered during a period when Java was gaining market appeal. Aside from web browsers, databases such as CouchDB and MongoDB employ JavaScript as its scripting and query language.
The following are characteristics of JavaScript:
JavaScript is used to develop interactive websites. Its major uses are:
<!DOCTYPE>
<html>
<body>
<h1>
Welcome to JavaScript</h1>
<script>
document.write("Hello JavaScript by JavaScript");</script>
</body>
</html>
When you look at the paragraph tag with the id demo, you will notice that there is no content in between and that the content is generated when the button is clicked.
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 Date and Time:
<!DOCTYPE>
<html>
<body>
<h1>
My First JavaScript</h1>
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
document.write("Click me to display Date and Time.");</button>
<p id="demo">
</p>
</body>
</html>
Total: RWF 0.00