Reputation: 363
I am able to create an array using the following code below. The issue with this is that, what if an individual enters 50 tacos. I am afraid the browser will go through an entire list looking for the rel attribute.
<ul id="taco">
<li rel="19">other html goes here</li>
<li rel="50">other html goes here</li>
<li rel="1535">other html goes here</li>
<li rel="875">other html goes here</li>
</ul>
$("#taco li").each(function() {
$tacoOrder.push($(this).attr('rel'));
});
So, I was thinking of putting the taco order values in an input box. For example my code looks like this.
<input value="19, 50, 1535, 875">
I want to take the value from this input and create an array. Is this even possible, or is it better to do an each function?
Upvotes: 0
Views: 36
Reputation: 1030
This can be one solution:
var liObj = $("#taco li");
//Convert the list to an Array
var arr = jQuery.makeArray(liObj);
Upvotes: 1