Image Comparison Slider with jQuery and CSS

The “imgSlider” is a lightweight, simple and easy to use image comparison slider plugin for jQuery. It is useful to show the before and after difference between two images. Users can easily see the difference by sliding the image with mouse / swipe. The plugin allows you to build slider with no tough work. You just need to add the images in div container, then this awesome plugin will dynamically create slider.

Moreover, the plugin can be customize with additional CSS accordion to your needs.

Plugin Overview

Plugin: imgSlider
Author: Kavya Sukumar
Licence: MIT Licence
Published: January 19, 2024
Repository: Fork on GitHub
Dependencies: jQuery 1.3.1 or Latest version
File Type: zip archive (HTML, CSS & JavaScript )
Package Size: 605 KB

How to Use jQuery Image Comparison Slider

1. First of all load jQuery JavaScript library and imgSlider plugin’s CSS and JavaScript file into your HTML page.

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- imgSlider JS -->
<script src="dist/imgslider.min.js"></script>

<!-- imgSlider CSS -->
<link rel="stylesheet" href="dist/imgslider.min.css">

2. After loading all necessary assets, create HTML div element and place your images (left and right) in it.

<div class="slider responsive">
   <div class="left image">
      <img src="path/to/img-before.jpg"/>
   </div>
   <div class="right image">
      <img src="path/to/img-after.jpg"/>
   </div>
</div>

The mentioned class names are required.
3. Finally, initialize the plugin in jQuery document ready function to active image slider.

$(document).ready(function(){

   $('.slider').slider();

});

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...