Jquery has an inArray() function var myArray = new Array(); var I = 0; $("li. Foo"). Each(function(){ var iBarCode = $(this).
Attr('barcode'); if( $. InArray(iBarCode, myArray) == -1 ){ myArrayi++ = iBarCode; //do something else } }).
Jquery has an inArray() function. Var myArray = new Array(); var I = 0; $("li. Foo").
Each(function(){ var iBarCode = $(this). Attr('barcode'); if( $. InArray(iBarCode, myArray) == -1 ){ myArrayi++ = iBarCode; //do something else } }).
1 your code is wrong,!($. InArray(iBarCode, myArray) fails if the element is in position 0. You should use!
~($. InArray(iBarCode, myArray) instead. – Ravan Jun 30 at 22:04 now my loop is not entering the if statement for any barcodes!
The myArray is blank at the end – sadmicrowave Jun 30 at 22:08 sadmicrowave, I wrote the if statement incorrectly, since inArray returns -1 if not found. I have updated the answer. – Gazler Jun 30 at 22:10 thank you that fixed it.
Just curious but is there a way to check if a value is in an array without jquery? Like indexOf() or something? – sadmicrowave Jun 30 at 22:12 indexOf is not supported in IE.
See this question. Stackoverflow. Com/questions/1744310/… – Gazler Jun 30 at 22:22.
The in keyword search for properties, for instance when you want to know if an object has some method available. Since you are looking for values, it always returns false. You should instead use an array search function as Gazler advises.
1 for explaining why the code isn't working. – Gazler Jun 30 at 22:00.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.