I have created a script `onClick` function not working with anchor tag I don't know why I am clicking on it and nothing is happening

```
$(".addname").on("click", function() {
  var username = $(this).attr('title');
  var old = $("#contentbox").html();
  var content = old.replace(word, "");
  $("#contentbox").html(content);
  var E = "<a class='red' contenteditable='false' href='#' >" + username + "</a>";
  $("#contentbox").append(E);
  $("#display").hide();
  $("#msgbox").hide();
  $("#contentbox").focus();
});

<div id="contentbox" contenteditable="true"></div>

if($_POST)
{
$q=$_POST['searchword'];
$q=str_replace("@","",$q);
$q=str_replace(" ","%",$q);
$sql_res=mysql_query("select * from users where name like '%$q%' order by id LIMIT 5");
while($row=mysql_fetch_array($sql_res))
{
$fname=$row['name'];

?>
<div class="display_box" align="left">
<img src="user_img/test.jpg" class="image"/>
<a href="#" class='addname' title='<?php echo $fname; ?>'>
<?php echo $fname; ?> </a><br/>
<?php
}
}
?>

```

Please see my above question now as of I am adding data dynamically and the button adding dynamically is included within the dynamic data coming from the other file