شرح صفوف ومحتوى الفقرة
تعيد الخاصية document.images مجموعة حية تضم كل عنصر <img> في الصفحة. تستخدمها أدوات فحص الجودة وسهولة الوصول للمرور بحلقة for...of أو الفهرس الرقمي لإحصاء الصور وفحص مساراتها والتأكد من وجود النص البديل alt.
JavaScript
function auditImages() {
const imgs = document.images;
let missingAlt = 0;
for (const img of imgs) {
if (!img.alt) missingAlt += 1;
}
const out = document.getElementById('img-audit');
out.textContent = 'Images: ' + imgs.length + ' | Missing alt: ' + missingAlt;
}