gpt4 book ai didi

javascript - 我该如何修复此错误 "There is no attribute colorcode, selected or tabindex"

转载 作者:太空宇宙 更新时间:2023-11-04 12:00:09 25 4
gpt4 key购买 nike

colorthumbs[i].addEventListener('click', function(){
var colorcode = this.getAttribute('colorcode');
var thumbimg = document.getElementById('productthumbs').getElementsByTagName('img');
for(var i = 0; i < thumbimg.length; i++) {
 <div id="colorpanel" style="border-bottom:1px solid lightgray;">
<p><b>Select Color</b></p>
<div class='productthumbs'>
<img class="thumbimg" src="Images/p1s1c1.jpeg" alt="color1" colorcode="1" selected="selected" style="border-color:brown;"/>
</div>
</div>

这必须是 xhtml strict 1.0,仅此而已。一直在处理大量错误,现在只剩下最后三个错误了。

第 83 行,第 92 列:没有属性“colorcode”第 83 行,第 105 列:没有属性“selected”第 117 行,第 94 列:没有属性“tabIndex”

最佳答案

HTML 中没有名为“colorcode”的属性,你从哪里得到colorcode="1"? selected 属性不适用于 img 标签,它适用于下拉菜单。从您的 img 标签中删除这两个。

我在您的代码中没有看到任何关于 tabindex 的内容,但我怀疑这是因为您将 index.html 中的“I”大写了。 XHTML 区分大小写,因此元素和属性名称通常为小写。

解决所有这三个问题,您的代码应该可以正常工作。

关于javascript - 我该如何修复此错误 "There is no attribute colorcode, selected or tabindex",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29884896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com