我想知道如何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")