I have the following code
<ul id="box1">
<li id="node3">Student C</li>
<li id="node1">Student A</li>
<li id="node2">Student B</li>
</ul>
I want to append into ‘node1’ some text field, how can I refer to it?
$("li[id^=node]:last").attr("id") – gives me the id of the object I added last, if I iterate through it, I get all the id’s i need, but now I know the id and want to insert into it.
I have tried before() and after(), but its of no use, I need to insert the text file inside the <li> tag. So the final would be like:
<ul id="box1">
<li id="node3">Student C</li>
<li id="node1">Student A <input type="text" name="studAValue" style="margin-left:25px"/> </li>
<li id="node2">Student B</li>
</ul>
Try
Working demo http://jsfiddle.net/uwXSR/