I want to write some text only into all the <li>
elements of 2nd unordered list.
You can use :eq(index)
Select the element at index n within the matched set.
Note: Zero-based index of the element to match
Use
$("ul:eq(1) li").text("Lorem Ipsum")
EDIT: Be wise to chooses between :eq()
and :nth-child()
See comparative example