Question: I have a graph in my webpage and whenever I click a point in my graph, I want a div to be updated with new content. Through my function, I managed to update it, but when I click on a new point, new content is added to the old one and so on, given that I want to have only the current content in my div.

Here's my function:

```
$(document).ready(function() {
    $(div_to_update).text(content);
});

```

}

I tried to implement 

```
$("#chart_div").click(function()
   $('#div_to_update').remove();
});

```

but obviously it removes my div and I'm unable to recover it then.

Answer: 
I my opinion, if you want to change data in a div when something is clicked,  

you could do it this way:

```
<script>
$(document).ready(function() {
   $(".point").click(function() {
      var content = $(this).attr('value');
      $("#div-to-update").html(content);
   });
});
</script>

```

in the body of your page...

```
<div id='graph'>
   <div class='point' value='10'>
   <div class='point' value='100'>
   <div class='point' value='1000'>
</div>

<div id='div-to-update'>
    // when point is clicked, content here will change
</div>

```
if you want to remove all child nodes of the set of matched elements from the DOM use `empty()`

```
$("#chart_div").click(function(){
    $("#div_to_update").empty();
});

```