本文實例講述了JS獲得圖片alt信息的方法。分享給大家供大家參考。具體如下:
下面的JS代碼可通過圖片的alt屬性獲得圖片的提示信息
<!DOCTYPE html><html><body><img id="compman" src="compman.gif" alt="Crazy computerman" width="107" height="98"><p>The value of the alt atrribute is:<script>document.write(document.getElementById("compman").alt);</script></p></body></html>希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答