I would like to do the following in the img
variable below: Get true if ALL images (img tag) are EQUAL or false if ONE OR MORE is DIFFERENT from the others. I tried loop for
, but it does not work as expected, because I could not find a way to compare each index with the others and get a single / em> or false . Faced with this, I had no idea what to do.
var img = '<img src="pic_1.jpg" />; <img src="pic_1.jpg" />; <img src="pic_1.jpg" />; <img src="pic_1.jpg" />'; // Todas as imagens são iguais - Daria true
var img = '<img src="pic_1.jpg" />; <img src="pic_2.jpg" />; <img src="pic_1.jpg" />; <img src="pic_1.jpg" />'; // Uma imagem é diferente das outras - Daria false
var img = '<img src="pic_1.jpg" />; <img src="pic_1.jpg" />; <img src="pic_2.jpg" />; <img src="pic_2.jpg" />'; // Duas imagens são diferentes das outras - Daria false
img = img.split(';');
for (var i = 0; i < img.length; i++) {
console.log(img[i] != img[0]);
}