jquery appending class to a class
ok I have a <ul id="classname"></ul>
can i insert '<li id="classname1"></li>
' in开发者_如何学Pythonside ul on form load using jquery ?
Yes, you can do it using .append()
, like this:
$(function() {
$("#classname").append('<li id="classname1"></li>');
});
Note that this is valid once, as an ID should be unique, if you actually meant classes, e.g.
<ul class="classname"><li class="classname1"></li></ul>
, then you'd do this:
$(function() {
$(".classname").append('<li class="classname1"></li>');
});
精彩评论