muk*_*und 4 javascript image alt
我想知道如何在javascript中为图像添加alt属性,下面是我的代码...
var image = document.createElement('img');
image.src='../../KY/images/common/buttons/browseIcon.png';
Run Code Online (Sandbox Code Playgroud)
提前致谢.
Big*_*ood 13
您有两种方法:可以使用alt属性
image.alt = "Your text here"
Run Code Online (Sandbox Code Playgroud)
或setAttribute方法
image.setAttribute("alt","Your text here");
Run Code Online (Sandbox Code Playgroud)