如果图片无法显示,有没有办法添加单独的替代文本(例如“图片 1/2 不可用”)?如何更改此代码以允许这种情况发生?
(Sridhar 的代码)
<script type = "text/javascript">
function pic1()
{
document.getElementById("img").src = "picture 1 source";
}
function pic2()
{
document.getElementById("img").src ="picture 2 source";
}
</script>
<img src = "" id = "img"/> <input type="button" value="Show Picture
1" onclick="pic1()"/> <input type="button" value="Show Picture 2"
onclick="pic2()"/>