简体   繁体   English

验证错误,过时的属性

[英]Validation error, obsolete attribute

I'm currently working on a web page. 我目前正在网页上。 Everything is working but when I went to validate, I ran into an error. 一切正常,但是当我进行验证时,我遇到了一个错误。 The W3C validator says the name attribute is obsolete. W3C验证器说name属性已过时。 Everything works, but no errors would be nice. 一切正常,但没有错误会很好。

line from About_me.html About_me.html中的一行

<img name="slide" alt="images about me" width="600" height="400">

line from slideshow.JS slideshow.JS的一行

function changeImg(){
    document.slide.src = images[i];

When I go to validate I get the following error "The name attribute on the img element is obsolete. Use the id attribute instead." 当我进行验证时,出现以下错误“ img元素上的name属性已过时。请使用id属性。” When I change name to id the slide show no longer works. 当我将名称更改为id时 ,幻灯片放映将不再起作用。 What to do? 该怎么办?

If you change the field of the img element from name to id, then you will have to use 如果将img元素的字段从name更改为id,则必须使用

document.getElementById("slide").src = images[i];

instead of just 而不只是

document.slide.src = images[i];

Hope this helps! 希望这可以帮助! :D :D

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

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