Basic JavaScript/jQuery example for begginers

- 1 min read

JavaScript (JS) is a dynamic computer programming language. It is most commonly used as part of web browsers, whose implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed. It is also being used in server-side programming, game development and the creation of desktop and mobile applications.

Basic JavaScript/jQuery example for begginers

This is a basic code example of how to make dissapear things in a web using JavaScript/jQuery. Just copy-paste it to the notepad, study it (trust me, is very simple) and run it in your browser.

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JavaScript Example</title>
    <script src="https://code.jquery.com/jquery-latest.min.js"></script>

    <style>
        #div_to_hide {
            background-color: DimGray;
            color: white;
        }
    </style>

    <script>
        $(document).ready(function () {
            $("#hide").click(function () {
                $("#div_to_hide").hide();
            });
            $("#show").click(function () {
                $("#div_to_hide").show();
            });
        });
    </script>

</head>
<body>

<button id="hide">HIDE TEXT</button>
<button id="show">SHOW TEXT</button>

<div id="div_to_hide">HI, IM THE MAGIC TEXT</div>

</body>
</html>

Share: Link copied to clipboard

Tags:

Previous: .htaccess basic configuration
Next: Europa Necesita Controlar la Inmigración

Where: Home > Technical > Basic JavaScript/jQuery example for begginers