i have a problem, i’m working with jquery and some ajax requests.
i’m getting a string like: 5 12 6 8
now i want to split this string into 5,12,6,8 and then add the numbers to some elements like:
$("#l1").html("5");
$("#l2").html("12");
$("#l3").html("6");
$("#l4").html("8");
the problem is, that there are not always 4 numbers, sometimes 8, other times just one. when there is just one it would be:
$("#l1").html("x");
x should be the number which i get.
how to resolve this with jquery?
Assuming that
stris a string that looks like “5 12 6 8”:Fiddle: http://jsfiddle.net/Sxucs/1/