Frage: Wie würde ich die src, Breite und Höhe aller Bilder auf einer Seite sammeln und dann jedes Mal, dass aktuelle Seite Größe ändert, zeigen Sie die Bildinformationen in der Konsole .Get Image Info und in der Konsole auf der Seite anzeigen Größe
Beispielcode:
var images = document.getElementsByTagName('img');
var srcList = [];
for(var i = 0; i < images.length; i++) {
srcList.push(images[i].src);
srcList.push(images[i].width);
srcList.push(images[i].height);
}
window.onresize=function(){
for(var i = 0; i < images.length; i++) {
console.log(srcList[i]);
}
//I am pretty sure I would have to go get the new width and height of the images on the page. Should I just loop through and populate the array like above? The source would stay the same.
};
Ich bin nicht sicher, wie das Array korrekt mit dem Bildinformationen zu aktualisieren und sobald ich sie alle Zugang haben sie es in der Konsolenprotokoll zu zeigen.
Drücken Sie 'Objekt' in' Array' – Rayon