如何用JS获得图片ALT属性中的内容
------解决方案--------------------------------------------------------
<img id= 't ' src= "xxx " alt= "abcd " onload= " " /> 7
<script> alert(document.getElementById( 't ').alt); </script>
------解决方案--------------------------------------------------------
<img id= "photo " alt= "我是图片 " />
方法一:
var obj = document.getElementById( "photo "); //引用对象
alert(obj.getAttribute( "alt "));
方法二:
var obj = document.getElementById( "photo ");
alert(obj.alt);