0

I have a list <li id="somelist"> </li>

I want to put a div inside it like this <div>SomeDiv</div>

The final output should be <li id="somelist"><div>SomeDiv</div></li>

How do I do this using jquery?

1
  • 2
    $('#someList').html('<div>SomeDiv</div>'); This is basic jquery you could learn from their site. Commented Jun 1, 2016 at 15:43

1 Answer 1

3

You can append <div>SomeDiv</div> to the li element:

$('li#somelist').append('<div>SomeDiv</div>');
Sign up to request clarification or add additional context in comments.

3 Comments

I thought append would grow the list. Would it insert inside the li element?
Yap, it will :) do what you want, inside the <li>
@BhagyashreeJog You're confusing append with after.

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.