JavaScript - Simple Flip Image Using jQuery
Submitted by razormist on Sunday, April 21, 2019 - 17:21.
In this tutorial we will create a Simple Flip Image using jQuery. This code can animate a flip effect on the images when the user click the button. The code itself use jQuery onclick function to manipulate the image stylesheet by adding a transform with a degree value, to be able to flip the image. This is a user-friendly program feel free to modify it.
We will be using jQuery a JavaScript framework that design to simplify HTML DOM tree traversal and manipulation. It can do more in a single line of code than JavaScript can do in a whole function.
There you have it we successfully created a Simple Flip Image using jQuery. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Getting Started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/. And this is the link for the jquery that i used in this tutorial https://jquery.com/.The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-widht, initial-scale=1"/>
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- </div>
- </nav>
- <div class="col-md-6 well">
- <hr style="border-top:1px dotted #ccc;"/>
- <br />
- </div>
- </body>
- </html>
Creating the Script
This code contains the script of the application. This code will flip the image when the button is clicked. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js directory- $("#flip").on("click",function(){
- if($("#imageTarget").css("transform") == 'none') {
- $("#imageTarget").css("transform","rotatey(180deg)");
- }
- else {
- $("#imageTarget").css("transform","");
- }
- })
Add new comment
- 210 views