📜  查找所有没有替代文本的图像 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:15.144000             🧑  作者: Mango

代码示例1
// find all images without alternate text and give them a red border
function processImages() {
  // Get all images
  const images = document.querySelectorAll('img')

  // Loop through all images
  images.forEach(image =>
    // If the image has no alt attribute give it a red border
    !image.alt ? (image.style.border = '1px solid red') : null
  )
}