I am using this script to insert three different span‘s to the 1st, 2nd and 3rd lis.
$("ul li:eq(0)").prepend("<span>1</span>");
$("ul li:eq(1)").prepend("<span>2</span>");
$("ul li:eq(2)").prepend("<span>3</span>");
Is there a way to refactor this code to remove the redundancy?
If you want to do it to all li tags that are there:
If there are more than three li tags and you only want it done to the first three:
Working jsFiddle here: http://jsfiddle.net/jfriend00/qhgad/