简体   繁体   中英

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. Everything works, but no errors would be nice.

line from About_me.html

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

line from 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." When I change name to id the slide show no longer works. What to do?

If you change the field of the img element from name to id, then you will have to use

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

instead of just

document.slide.src = images[i];

Hope this helps! :D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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