开发者

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>');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜