Dot(.) class selector, click on a button, the elements with class="test" will be hidden

 <!DOCTYPE html>

<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $("button").click(function () {
            $(".test").hide();
        });
    });
</script>

</html>

<body>
    <h2 class="test">This is a heading</h2>
    <p class="test">This is a paragraph</p>
    <p>This is another paragraph</p>
    <button>Click me</button>
</body>

Comments

Popular posts from this blog

Basic Syntax in jQuery

Event "Target" Property in jQuery