<div id="btn_answer_1">
<a href="#" id="answer_add1" style="display: block;border: 1px solid; width: 100px; height: 20px;"></a>
</div>
<div id="btn_answer_2">
<a href="#" id="answer_add2" style="display: block;border: 1px solid; width: 100px; height: 20px;"></a>
</div>
window.onload = function(){
document.getElementById('answer_add1').onclick = function(){
alert(this.parentNode.id);
};
document.getElementById('answer_add2').onclick = function(){
alert(this.parentNode.id);
};
};