Switching Images

Developer
Size
2,412 Kb
Views
26,312

How do I make an switching images?

When one image is hovered over, the two images swaps.. What is a switching images? How do you make a switching images? This script and codes were developed by Lauren on 18 September 2022, Sunday.

Switching Images Previews

Switching Images - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Switching Images</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ * { margin: 0px; padding: 0px; border: 0px;
}
html, body { background: #8eb7a4; text-align: center; width: 100%; height: 100%;
}
#img1 { background: url('https://columbia.edu/~ljz2112/resources/mid-december_200x200.png');
}
#img2 { background: url('https://columbia.edu/~ljz2112/resources/shed-some-light_200x200.png');
}
#img1, #img2 { display: inline-block; margin: -100px 20px 0px; position: relative; top: 50%; border-radius: 10px; border: 1px #06312c solid; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2); width: 200px; height: 200px; cursor: pointer; transition: all 0.2s linear 0s
}
#img1:hover, #img2:hover { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="img1"></div>
<div id="img2"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Switching Images - Script Codes CSS Codes

* { margin: 0px; padding: 0px; border: 0px;
}
html, body { background: #8eb7a4; text-align: center; width: 100%; height: 100%;
}
#img1 { background: url('https://columbia.edu/~ljz2112/resources/mid-december_200x200.png');
}
#img2 { background: url('https://columbia.edu/~ljz2112/resources/shed-some-light_200x200.png');
}
#img1, #img2 { display: inline-block; margin: -100px 20px 0px; position: relative; top: 50%; border-radius: 10px; border: 1px #06312c solid; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2); width: 200px; height: 200px; cursor: pointer; transition: all 0.2s linear 0s
}
#img1:hover, #img2:hover { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
}

Switching Images - Script Codes JS Codes

$(document).ready(function() { var img1 = $('#img1').css('background-image'); var img2 = $('#img2').css('background-image'); $('#img1').hover(function() { $('#img1').css('background-image', img2); $('#img2').css('background-image', img1); }, function() { $('#img1').css('background-image', img1); $('#img2').css('background-image', img2); }); $('#img2').hover(function() { $('#img1').css('background-image', img2); $('#img2').css('background-image', img1); }, function() { $('#img1').css('background-image', img1); $('#img2').css('background-image', img2); });
});
Switching Images - Script Codes
Switching Images - Script Codes
Home Page Home
Developer Lauren
Username phantomesse
Uploaded September 18, 2022
Rating 3
Size 2,412 Kb
Views 26,312
Do you need developer help for Switching Images?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Lauren (phantomesse) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!