I am new to web programming.Actually I want to create a list in that I have to add elements dynamically to unordered list.I added elements in list dynamically but I have to anchor tag to that each list item.please help me
HTML:
<div data-role="main" class="ui-content">
<input type="button" id="btnid" onclick="getData()"/>
<p id="p1">
Insert Content Here working
</p>
<ul data-role="listview" data-inset="true" id="ulist" title="nodes list" data-inset="true">
</ul>
</div>
JavaScript:
for (var i = 0; i < jsonData.Element.length; i++) {
var counter = jsonData.Element[i];
//console.log(counter.counter_name);
var newelement=$("<li>"+counter.nodeName+" "+counter.activeCount+" "+counter.inactiveCount+"</li>");
newelement.appendTo("#ulist");
// alert(counter.nodeName);
}
Try with this.
$("<li><a href='#'>"+counter.nodeName+" "+counter.activeCount+" "+counter.inactiveCount+"</a></li>").appendTo("#ulist");
Please try with above code snippet. Let me know if you want to set URL based on your field's value.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments