Question: I'm updating the user posts via this code:

```
var auto_refresh = setInterval(function() 
{
    $('.contenido-publicaciones')
        .load("refresh_p.php?search_user="+search_user).fadeIn();
}, 2500 ); //Which is working.

```

1: `<div class="contenido-publicaciones">`, all the `<div class="this-is-a-post">` div's from refresh.p.php load here every 2,5 seconds.

2: I have a textarea tag inside for each `<div class="this-is-a-post">` that refreshes from `refresh_p.php`.

3: When `<div class="contenido-publicaciones">` refreshes, it also refresh the textarea and prevent the user for typing.

4: All of the textareas have the class `b_green`

I want to `clearInterval(auto_refresh)` when the user clicks a textarea with the class `b_green` so another user can send a comment to that post.

I've tried the following:

`$(".b_green").click(function(){
clearInterval(auto_refresh);
});` // Didn't work, `<div class="contenido-publicaciones">` keep refreshing.

`$("textarea").click(function(){
clearInterval(auto_refresh);
});` // Works only when i click a textarea that i have on the top of the page to send posts, but doesn't work when i click a textarea with the class b\_green.

`$(this).click(function(){
clearInterval(auto_refresh);
});` //This works if i click on b\_green textareas, but stop the Interval on every click that the user does on the page, I only want to stop on b\_green textareas click.

Is there any error on my code? Any help would be appreciated.

Answer: 
The clicks do not fire because at the time you are binding them there are no textareas or the ones that there are are latter replaced with new ones. These new textareas do not have the onclick handler attached.

You could do either of these:

1. Add `onclick="clearInterval(auto_refresh);"` to the code of the textarea that backend sends and get something like:

```
<textarea onclick="clearInterval(auto_refresh);"></textarea>

```
2. Use `on` to bind the click handler to a higher element that remains on the page like so:

```
$(".contenido-publicaciones").on('click', 'textarea', function(){
    clearInterval(auto_refresh);
});

```
As I understood your loaded content contains all nodes which you are trying to handle by click.

If so . There is an issue. Because each time you get update you loose click handlers, because DOM has changed. as + you probably have memory leak here from previous "unreachable" handlers