繁体   English   中英

我想使用事件处理程序引用 img 的 alt 文本。 如何在函数中引用 img 标签

[英]I want to reference an img's alt text using event handlers. How do I reference the img tag in a function

在此处输入图片说明

假设我想显示 creek 的替代文字。 如何在函数中使用 html DOM alt 属性来定位该特定图像

你可以通过它的属性访问它

var altText = cr.alt

这里有一些参考https://www.w3schools.com/jsref/prop_img_alt.asp

检查图像 alt: cr.alt返回它: alert(cr.alt)更改图像 alt: cr.alt = 'your new alt';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM