“ITerate Over Array of HTML Elements” Kode Jawaban

Loop html melalui array

var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Grepper

ITerate Over Array of HTML Elements

const imgs = document.querySelectorAll(".img");
    // You can't simply use imgs.forEach as it is not exactly an array. To fix that, first convert it to an array and then iterate.
	[...imgs].forEach(img => {
			console.log(img);
	});
Bloody Booby

Jawaban yang mirip dengan “ITerate Over Array of HTML Elements”

Pertanyaan yang mirip dengan “ITerate Over Array of HTML Elements”

Lebih banyak jawaban terkait untuk “ITerate Over Array of HTML Elements” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya