I am trying to pass a string in the onClick event handler function\'s arguments of the dynamically created anchor element, see the fiddle http://jsfiddle.net/shmdhussain/bXYe4/.
Your problem is, that str+="dd"; will return a string like "dd". This will generate a html like this:
str+="dd";
"dd"
dd
In this case, the onclick attribute contains only 'test('.
Try this:
This will generate a html like this: