在数组中添加 alt 属性
Adding an alt attribute in an Array
我是JavaScript的新手,试图弄清楚如何将Alt属性添加到数组中。这是我到目前为止所拥有的。我将如何将其添加到何处?我在正文/表格中添加 alt=' ",但显然这不起作用。
<script type="text/javascript">
var pictures = new Array();
pictures[0] = new Image();
pictures[0].src = "image.jpg";
pictures[1] = new Image();
pictures[1].src = "image2.jpg";
<body>
var x = "<table>";
for (var y=0; y<rows; y++) {
x += "<tr> ";
for (var j=0; j<columns; j++) {
var ix = (y * rows + j) % pictures.length;
var id = y + "-" + j;
x += "<td> <img src=' " + pictures[ix].src +
"' " +
" id='" + id + "' " +
" height='300' width='300' ></td>";
">
Alt"以防图像无法正确显示,因此将显示属性中的文本。
x += "<td> <img src=' " + pictures[ix].src +
"' " +
" id='" + id + "' " +
" height='300' width='300' alt='image_" + j + "' ></td>";
相关文章:
- 连接标记和img alt属性的不同textContext
- 使用jquery将远程html-alt属性加载到另一个使用for循环和数组的页面中
- 在其自己的图像之后显示 Alt 属性
- img文件名作为CSS中的title和alt属性
- 在数组中添加 alt 属性
- 如何添加 alt 属性
- 如何使用jquery添加img标签的alt属性
- 使用 Angularjs 中的单选按钮动态添加 url 和 alt 属性
- 使用量角器断言网页上所有图像的 Alt 属性
- 有没有办法使用 fancybox 在“alt”属性中添加 HTML 代码
- 获取同级的alt属性值,并将其存储到jquery中的变量中
- 目标<img>通过jQuery中的alt属性
- 如何迭代具有特定img alt属性的表行并删除javascript中的单元格
- 如何自动调整图像的屏幕大小从Alt属性,而不是src
- 添加Alt属性从值的scr名称在整个网站在Jquery
- 复制图片的alt属性为<文本(并覆盖它)在jQuery / Javascript
- 如何编写一行可以添加到showpic函数末尾的代码,该函数更新占位符元素上的alt属性
- getSelection中没有alt属性和脚本
- html中Image标记的alt属性
- Alt属性的问题