javascript - Adding a hyperlink dynamically in html using jquery -
for (i = 0; < crowcount / 5; i++) { link = $('<a/>').attr({ href : '#', id : $(this).attr('id') + (i + 1), class: 'mylink' }); $(this).append(link + " "); }
when appending link component not giving me link. instead showing following thing without hyperlink.
[object object] [object object] [object object]
problem line $(this).append(link + " ");
line converting object string, because appending object string
you can
html
<div>abc </div>
code append
for (i = 0; < 10 / 5; i++) { link = $('<a/>').attr({ href : '#', id : $(this).attr('id') + (i + 1), class: 'mylink' }); link.html(i ); $("div").append(link ); $("div").html($("div").html() + " " ); }
Comments
Post a Comment