How to orginize substitution of array of data on Jquery?
I have array of data in external file like this:
var prod = [];
prod[0] = ['one', 'two', 'three'];
prod[1] = ['four', 'five', 'six'];
...
In html files I want to paste
<tr>
<td class="prodname">prod[4][1]</td>
<td class="prodnum">prod[4][2]</td>
<td class="mprice_el">prod[4][3]</td>
</tr>
and by call function fill(); necessary to substitute data from the array.
I try like this:
function fill(){
var prodname;
var prodnum;
var prodprice;
$('.prodname').each(function(){
for (var i = 0; i < prod.length; i++) {
$(this).html(prodname);
}
}
}
But don’t know how to get id from html and compare it with array.
If I understand correctly, you’re looking for something like this (though you would probably want to validate the results):
Example: http://jsbin.com/anusoj/3