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: September 27, 2019
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();

});