How to add Html element to dynamic list in jquery

skyshine

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);            
}
Jayesh Goyani

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add Html element to dynamic list in jquery

From Dev

How to add dynamic element jquery?

From Dev

How to dynamic add and remove element by jQuery?

From Dev

How to add and select an element in html using jquery

From Dev

add html element with jquery

From Dev

add html element with jquery

From Dev

how to add dynamic read more toggle for html string by jquery?

From Dev

How to add an element to a list?

From Dev

How to add an element to a list?

From Dev

How to add this element in jquery

From Dev

How to add this element in jquery

From Dev

Add spaces to list element HTML

From Dev

How to remove a class in a list of elements and add to another element Jquery?

From Dev

jquery .add() not adding html element

From Dev

jquery .add() not adding html element

From Dev

Add classes to html element with jQuery

From Dev

How do you add a list id to a newly created HTML element?

From Dev

How do I add html tags after the last element with jQuery?

From Dev

How do I add html tags after the last element with jQuery?

From Dev

How to add a new attribute for a HTML element before added to DOM with jQuery

From Dev

Select dynamic HTML Element via jQuery

From Dev

Add dynamic HTML with JQuery without hard coding?

From Dev

how to add dynamic data with jquery add function?

From Dev

how to add element in jquery append

From Dev

how to add to an HTML time element

From Dev

jquery remove and add class in list element

From Dev

Add multiple html element dynamically using jquery

From Dev

With jQuery, can you add an HTML element like this?

From Dev

How to add element to a list, inside another list?

Related Related

HotTag

Archive