I have the following code:
var nowa = [];
var tab = [{'material':'221214', 'item':'SPRITE 0,33LX24PUS', 'quantity':'2', 'jedn':'CS'}];
$.each(tab, function(index, w) {
if(($.inArray(w.material, nowa)) == -1){
nowa.push(w.material);
if(w.item == '0,33')
rodzaj = 'can';
if(w.item == '0.5')
rodzaj = 'pet';
$('table.new').append('<tr class="'+w.material+'" id="'+rodzaj+'"><td>'+w.material+'</td><td>'+w.item+'</td><td class="qq">'+w.quantity+'</td><td>'+w.jedn+'</td></tr>');
}
});//each
How to compare w.item with other text in this case?
Because this:
if(w.item == '0,33')
rodzaj = 'can';
is not working.
w.item values can be:
0,5
0.5
0.33
1,0
1.5
2,5
and other.
You can use
So your comparison will look like
Read more about .search()