Jquery to change HTML

text color [closed]

I just started trying to learn JQuery. I wanted to make a

change color on anchor click, but this code isn’t working and I can’t figure out why. I know this is very basic but it is the first step to me learning JQuery.

main.js :

jQuery(function ($) {
    $('#test').click(function () {
         $("p").css("color", "yellow");


<!DOCTYPE html>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="">

    <a id="test" href="#">


    <script src="main.js"></script>


You should import jQuery library.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Ref: https://www.w3schools.com/jquery/jquery_get_started.asp

Leave a Reply

Your email address will not be published. Required fields are marked *