1

ok I have a <ul id="classname"></ul> can i insert '<li id="classname1"></li>' inside ul on form load using jquery ?

1
  • 1
    That's an ID, not a class name. Commented May 19, 2010 at 14:50

1 Answer 1

5

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>');
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.