# Trigger Click Events with jQuery

**URL:** <https://forum.freecodecamp.org/t/trigger-click-events-with-jquery/172456>\
**Category:** General\
**Created:** [February 2, 2018, 6:56pm UTC](https://forum.freecodecamp.org/t/trigger-click-events-with-jquery/172456 "2018-02-02T18:56:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucianodouglasmc](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucianodouglasmc/32/77511_2.png) [@lucianodouglasmc](https://forum.freecodecamp.org/u/lucianodouglasmc)\
**Post date:** [February 2, 2018, 6:56pm UTC](https://forum.freecodecamp.org/t/trigger-click-events-with-jquery/172456/1 "2018-02-02T18:56:55Z")

</div>

**Tell us what’s happening:**  
In this section, we’ll learn how to get data from APIs. APIs - or Application Programming Interfaces - are tools that computers use to communicate with one another.

We’ll also learn how to update HTML with the data we get from these APIs using a technology called Ajax.

First, let’s review what the $(document).ready() function does. This function runs such that all of the code inside of it executes only once our page has finished loading.

So Let’s start by implementing a click event handler inside of our $(document).ready() function by adding this code:

$("#getMessage").on(“click”, function(){

});  
After completing this, proceed to the next challenge where we will make our “Get Message” button change the text of the element with the class message.

**Your code so far**

```auto
<script>
  $(document).ready(function() {
    // Only change code below this line.
    
    // Only change code above this line.
  });
</script>

<div class="container-fluid">
  <div class = "row text-center">
    <h2>Cat Photo Finder</h2>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12 well message">
      The message will go here
    </div>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12">
      <button id = "getMessage" class = "btn btn-primary">
        Get Message
      </button>
    </div>
  </div>
</div>

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/trigger-click-events-with-jquery](https://www.freecodecamp.org/challenges/trigger-click-events-with-jquery)

---

<div class="post-metadata">

**Author:** ![Loveaanthony](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/loveaanthony/32/77660_2.png) [@Loveaanthony](https://forum.freecodecamp.org/u/Loveaanthony)\
**Post date:** [February 3, 2018, 9:53am UTC](https://forum.freecodecamp.org/t/trigger-click-events-with-jquery/172456/3 "2018-02-03T09:53:44Z")

</div>

You can simple call the click event on the button:

```auto
$("button").click();

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:28pm UTC](https://forum.freecodecamp.org/t/trigger-click-events-with-jquery/172456/4 "2021-01-17T20:28:07Z")

</div>

Closed on January 17, 2021, 8:28pm UTC


