How can I append "LI" tag to "UL" tag of a DIV with this data-id?
Where should I add UL ?
$('[data-id="car-model"]').append($('<li></li>', {value:1, text:'One'}));
You're really close with your code you just have to append an li and then add the ul to your selector.
$('[data-id="car-model"] ul').append($('<li>', {
html: "Really new item"
}));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div data-id="car-model">
<ul>
<li>Test1</li>
<li>Test2</li>
</ul>
</div>
html attribute rather than the text attribute if he's just trying to set the text?value:1, I suppose, in this context, it doesn't matter. But since he may want to bolden text at some point, I think html is a better option. Nevertheless, edited out.Get the ul within the element by updating the selector([data-id="car-model"] ul) and append li to it.
$('[data-id="car-model"] ul').append($('<li></li>', {
text: 'One'
})
);
<li>elements don't havevalueattributes. That's only for input fields.