HTML DOM Image alt attribute
Definition and Usage
alt property sets or returns the image alt attribute values.
Replacement text alt attribute specifies the image does not display properly (Suman, image link errors) appears after.
Note: The text prompt will appear after Internet Explorer browser mouse over img element, which is not the norm, according to the HTML specification.All other browser only displayed when pictures can not display alt text.
Tip: If you want to create an image toolbar, use the title attribute.
grammar
imageObject.alt=text
Browser Support
All major browsers support the alt attribute
Examples
Examples
Return to image replacement text:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<img id="compman" src="compman.gif" alt="Crazy computerman" width="107" height="98">
<p>alt属性值为:
<script>
document.write(document.getElementById("compman").alt);
</script>
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<img id="compman" src="compman.gif" alt="Crazy computerman" width="107" height="98">
<p>alt属性值为:
<script>
document.write(document.getElementById("compman").alt);
</script>
</p>
</body>
</html>
try it"
Image Object