FBJS DHTML problem with OnClick

I am trying to add dynamic HTML element (EX. <div><a href=“#” onClick=“deleteFriend(‘id’);” >[delete]</a></div>),everytime on a event call using FBJS.I am able to append the element using following code.

var oldFriendHtml = document.getElementById(‘friend_container’);
var numi = document.getElementById(‘theValue’);
var num = (document.getElementById(“theValue”).getValue()-1)+2;
numi.value = num;
var newElementId = “new”+num;
var newFriendHTML = document.createElement(‘div’);
newFriendHTML.setInnerXTML(“HTML TO BE ADDED”);

The problem I am facing is that FBJS parses out the onClick part (event call ) out from the original HTML added .This stops me in the further activity on the added element .It also removes the styling added in the HTML …