Javascript fade in fade out without Jquery and CSS3

前端 未结 6 523
南方客
南方客 2020-12-03 11:28

I am really squeezing my head to make the simple fade in and fade out of the background image work only with javascript without JQuery and CSS3. I know how easy is to call a

6条回答
  •  北海茫月
    2020-12-03 11:40

    getElementById givies you one element (or null), getElementsByClassName gives an array.

    function handleClick(evt){
        var element = document.getElementById(evt.target.id);
        fade(element);
    
    }
    

    You seem to aim for usage of ID's, so this should answer your needs. I updated the whole thing: IDs

    However, you should realize that this method of fading is much more costly than using GPU accelerated transitions.

    Update
    JSfiddle webkit opacity fade

提交回复
热议问题