javascript - How to toggle element visibility without jQuery? -


i'm writing auction template ebay, hoping ebay allow it. apparently don't because jquery has things string.replace() etc.

the code basic.

$(document).ready(function(){      function changeimage(){         if($("#coin1").css("display") == "none"){               $("#coin1").fadein("slow");         }else{               $("#coin1").fadeout("slow");         }     };      setinterval ( changeimage, 5000 ); }); 

i need rewrite in plain javascript...

if can live without fading effect, should pretty straightforward:

function changeimage() {     var image = document.getelementbyid('coin1');     image.style.display = (image.style.display == 'none') ? 'block' : 'none'; }  setinterval(changeimage, 5000); 

while fading cool , all, it's makes code lot more complicated, when not allowed use external libraries. basically, need deal additional timers, firing short intervals, changing opacity of target element on each callback.

if want fading, see "javascript tutorial - simple fade animation".


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -