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/.
If I didn't misunderstand your question, here is your answer;
var elem=[ {"name":"husain","url":"http://google.com","age":21},
{"name":"ismail","url":"http://yahoo.com","age":22},
{"name":"nambi","url":"http://msn.com","age":23}
]
jQuery(function($){
var str="";
for(i=0;i',{href:'#',text:'dd'});
a.click(function(e){
test(elem[i].url)
});
$('.mytest').append(a).append($('')).append($(''));
}
});
function test(url){
console.log("url is "+url);
}