I want to append <li> in <ul> using jQuery. I’ve done it successfully with the following line:
var ChosedItem = $("#chosedItem");
ChosedItem.append('<li id=' + $(this).attr('id') + ' limit=' + $(this).attr('limit') + ' ><span>' + $(this).children(0) + '</span></li>');
in this, #chosedItem is the div id where the <ul> exists
But the problem in my case is if my <li> items contain spaces then it is not added after [0]th position of children because I am using chlidren(0). What can I use in place of children(0) to add <li> items that contain multiple spaces?
Try this