Paramclasses Academy - Blog

Tutorials Details

JavaScript Tutorial for Beginners: Learn Basics

JavaScript Tutorial for Beginners: Learn Basics

December 5, 2024

JavaScript is a powerful programming language for creating dynamic and interactive web applications. With JavaScript, you can manipulate the Document Object Model (DOM), validate user input, and enhance user experiences with animations and transitions. Input fields allow users to provide data, which JavaScript can process and output dynamically on the screen. For example, a form input can take a user's name and display a personalized greeting. The possibilities with JavaScript are vast, from creating simple calculators to complex applications. Start your JavaScript journey by learning its basics and experimenting with small projects to build your skills step by step.

Example:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>JavaScript Input and Output Example</title>

    <style>

        body {

    font-family: Arial, sans-serif;

    background-color: #f4f7fc;

    display: flex;

    justify-content: center;

    align-items: center;

    height: 100vh;

    margin: 0;

}

 

.container {

    background-color: white;

    padding: 20px;

    border-radius: 8px;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

    text-align: center;

    max-width: 400px;

    width: 100%;

}

 

h1 {

    font-size: 24px;

    margin-bottom: 10px;

}

 

.input-section input {

    padding: 10px;

    font-size: 16px;

    margin-right: 10px;

    border: 1px solid #ccc;

    border-radius: 4px;

    width: 60%;

}

 

.input-section button {

    padding: 10px 20px;

    font-size: 16px;

    background-color: #007BFF;

    color: white;

    border: none;

    border-radius: 4px;

    cursor: pointer;

}

 

.input-section button:hover {

    background-color: #0056b3;

}

 

.output-section {

    margin-top: 20px;

    font-size: 18px;

    color: #333;

}

 

    </style>

</head>

<body>

    <div class="container">

        <h1>Welcome to the JavaScript Tutorial</h1>

        <p>Please enter your name to receive a personalized greeting.</p>

 

        <!-- Input form -->

        <div class="input-section">

            <input type="text" id="nameInput" placeholder="Enter your name" />

            <button onclick="greetUser()">Greet Me</button>

        </div>

 

        <!-- Output section -->

        <div class="output-section">

            <p id="greetingMessage"></p>

        </div>

    </div>

 

    <script >function greetUser() {

        var name = document.getElementById('nameInput').value;

        var greetingMessage = document.getElementById('greetingMessage');

   

        if (name) {

            greetingMessage.textContent = 'Hello, ' + name + '!';

        } else {

            greetingMessage.textContent = 'Please enter your name.';

        }

    }

    </script>

</body>

</html>

 

 

 

 

Copyright © Paramwebinfo Academy.All Rights Reserved

Designed by PARAMWEBINFO