我想知道如何alt属性中的JavaScript添加到图像,下面是我的代码...提前添加alt属性图像中的JavaScript
var image = document.createElement('img');
image.src='../../KY/images/common/buttons/browseIcon.png';
感谢。
我想知道如何alt属性中的JavaScript添加到图像,下面是我的代码...提前添加alt属性图像中的JavaScript
var image = document.createElement('img');
image.src='../../KY/images/common/buttons/browseIcon.png';
感谢。
有两种方式:您可以使用alt财产
image.alt = "Your text here"
或setAttribute方法
image.setAttribute("alt","Your text here");
你可以只使用alt property。当u创建按钮或DOM JavaScript的任何其他元素
上述方法是行不通的,为此使用下面提到的方法
control.setAttribute("title","your tooltip value")