Change Background Image

Change Background Image With Button in HTML

 

It’s a good practice to use indentation. Your issue would never happen if you use:

function swap()
{
  if (document.getElementById("pic").src.endsWith('Design/b1.jpeg') != -1) 
  {
    document.getElementById("pic").src = "Design/b1.jpeg";
  }
} // <= your error

LEAVE A REPLY

Please enter your comment!
Please enter your name here