<p>You can listen to the add button's <code>click</code> event like so:</p>

<pre><code>$('.matrix &gt; .buttons &gt; .add').on('click', function(e) {
    // your js
});
</code></pre>

CC BY-SA 3.0
2015-06-21T14:27:25.647Z
2015-06-21T14:27:25.647Z
Bob Olde Hampsink
<p>I'm trying to call the addBlock function from the Matrix fieldtype. Whenever a block is added i need to run some basic javascript. 
Does anyone have an idea how to go about this?
thanks!</p>

<plugin-development><matrix>
Extending the matrixinput class
# Extending the matrixinput class

(Asked by: username_0 on 2014-10-23)

I'm trying to call the addBlock function from the Matrix fieldtype. Whenever a block is added i need to run some basic javascript.
Does anyone have an idea how to go about this?
thanks!

**Tags:** plugin-development, matrix


---

## 1 answers

### Answer by username_1 on 2015-06-21. Score: 2

You can listen to the add button's click event like so:
$('.matrix > .buttons > .add').on('click', function(e) {
    // your js
});


---

