how to create onclick for a link

href, javascript, jquery, onclick

Solution

You can set a onclick function:

document.getElementById('attachmentName').onclick = function() {};

Problem

i have a `div` for which i set value dynamically during run time, if there is value than i have enable or create a link which will have `onclick` method where i will call a `javascript` method. how to do this in `jquery` or `javascript`? I set value to a `div` like the following, ``` document.getElementById('attachmentName').innerHTML=projectInforamtionMap.Cim_AttachmentNames; ``` this the div : ``` <tr> <td align="left"><div id="attachmentName"> </div></td> </tr> ``` Kindly help me to find and fix. Best Regards

Original source