If by the last li on each line of ul you mean the last li in each ul , then:
$('ul li:last-child');
However, if you mean that you have li inside the same ul , written on several lines in the source code, and now you want to get the last on each line, then the answer will be that you cannot. The DOM does not care about your newline characters in your code.
Note: the correct way to do this is to give li separate class.
<ul> <li></li><li></li><li class="last"></li> <li></li><li></li><li class="last"></li> <li></li><li></li><li class="last"></li> </ul>
Now you can use CSS
li.last { color: #444 }
and jQuery
$('li.last');
the right way...
source share