javascript - Finding the ul inside a div and append li tag to that ul using jquery -
i want find ul element inside div , append li tag inside ul using jquery. given below in code parent div id=select_name_chosen,i want find ul class="chosen-results , append li in div using jquery. please solve issue. jquery code using.
var parent = $("div#select_name_chosen"); var childul = parent.children('.chosen-results'); childul.append($("<li class='active-results' data-option-array-index='0'>name</li>")); <div class="chosen-container chosen-container-multi chosen-with-drop chosen-container-active" style="width: 350px;" title="" id="select_name_chosen"> <ul class="chosen-choices"> <li class="search-field"> <input type="text" value="select subject" class="default" autocomplete="off" style="width: 110px;" tabindex="4"> </li> </ul> <div class="chosen-drop"> <ul class="chosen-results"> </ul> </div> </div>
this should work,it appends li elements ul of class='chosen-results'.
$("#select_name_chosen").find("ul[class='chosen-results']").append("<li class='active-results' data-option-array-index='0'>name</li>");
fiddle: https://jsfiddle.net/fos2lrab/
Comments
Post a Comment