javascript - Create a list with anchor tag inside -


i have list of <a> tag inside <ul> inside <div>

html

<div id="dd" class="wrapper-dropdown-1" tabindex="1"> <span class="summary-texts">summary </span>     <ul class="dropdown">         <li>             <a class="group" id="group-a">group </a>         </li>         <li>             <a class="group" id="group-b">group b </a>         </li>         <li>             <a class="group" id="group-c">group c </a>         </li>     </ul> </div> 

now, they're hardcode in html, , goal re-construct list using js. i'm little stuck trying make happen.


i've tried

for (var assignment in objects.assignments ) {    var dropdown = $("#dd").find(".dropdown");   var entry = document.createelement('li');   dropdown.appendchild(entry);   var = createelement('a').appendto(dropdown.find("li"));   a.setattribute('href', "" );   a.innerhtml = "group "+assignment; } 

error

uncaught typeerror: dropdown.appendchild not function

can please give me little here ?

any hints / helps / suggestions huge me.

because dropdown jquery object, cannot call appendchild methods on it.

use jquery add/append elements follow:

for (var assignment in objects.assignments) {     $("#dd .dropdown")         .append('<li><a href="">group ' + assignment + '</a></li>'); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -