JQuery multiple sliders on same page | how we can add multiple custom sliders on a single page using JQuery/Javascript and CSS3

1,293 views


Hey guys, today in this post we are going to learn about How to create a custom multiple sliders on same page in jQuery.

Files we used in this post example:-

multipleSlider.html HTML File It is used for create a slider for display the browser.
multipleSliderScript.js JavaScript File It is holding JavaScript Functioality
multipleSliderStyle.css Style CSS File It is used for slider alignment of slider image.
jQuery Library JQuery Library Min File It is a JQuey Library that is provided by JQuery

Final Output

w3web.net -- multiple slider in jquery

 

You can download file directly from github by Click Here.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
   

 

 

Other related post that would you like to learn in Salesforce

 

Download Supported jQuery Library for Slider Plugin

Step 1:- Create HTML File : multipleSlider.html

multipleSlider.html [HTML File]

  1.   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>w3web.net -- jquery multiple sliders on same page </title>
  6. <script type="text/javascript" src="http://w3web.net/wp-includes/js/jquery-1.7.1.min.js"></script>
  7. <script type="text/javascript" src="js/multipleSliderScript.js"></script>
  8. <link rel="stylesheet" href="css/multipleSliderStyle.css" type="text/css" media="all">
  9. </head>
  10.  
  11. <body>
  12. <div id="sliderContainer">
  13.   <span><a href="#" class="pre" title="Previous"><abbr style="font-size:60px;">&ltri;</abbr></a></span>
  14.   <span><a href="#" class="nxt" title="Next"><abbr style="font-size:60px;">&rtri;</abbr></a></span>
  15.    <div class="over">
  16.       <ul class="sliderList">
  17. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider1.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  18. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider2.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  19. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider3.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  20. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider4.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  21. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider5.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  22. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider6.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  23.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider7.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  24.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider8.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  25.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider9.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  26.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider10.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  27. 	   </ul>
  28.    </div>
  29. </div>
  30.  
  31. <br />
  32. <br />
  33.  
  34. <div id="sliderContainer1">
  35.   <span><a href="#" class="pre" title="Previous"><abbr style="font-size:60px;">&ltri;</abbr></a></span>
  36.   <span><a href="#" class="nxt" title="Next"><abbr style="font-size:60px;">&rtri;</abbr></a></span>  
  37.  
  38.    <div class="over">
  39.       <ul class="sliderList">
  40.          		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider6.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  41.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider7.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  42.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider8.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  43.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider9.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  44.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider10.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  45. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider1.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  46. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider2.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  47. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider3.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  48. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider4.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  49. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider5.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  50. 	   </ul>
  51.    </div>
  52. </div>
  53.  
  54. <br />
  55. <br />
  56.  
  57. <div id="sliderContainer2">
  58.   <span><a href="#" class="pre" title="Previous"><abbr style="font-size:60px;">&ltri;</abbr></a></span>
  59.   <span><a href="#" class="nxt" title="Next"><abbr style="font-size:60px;">&rtri;</abbr></a></span>  
  60.  
  61.    <div class="over">
  62.       <ul class="sliderList">
  63.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider9.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  64.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider10.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  65. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider1.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  66. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider2.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  67. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider3.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>		
  68.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider7.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  69.          <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider8.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>         
  70.           <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider4.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  71. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider5.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  72. 		 <li><img src="https://www.w3web.net/wp-content/uploads/2020/08/w3webSlider6.png" width="100" height="90"  alt="w3web.net Javascript Slider Plugin"></li>
  73. 	   </ul>
  74.    </div>
  75. </div>
  76. <br/>
  77.    <!--Start RelatedTopics Section-->
  78. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  79.  
  80.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  81.  
  82.             <br/><br/>
  83.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like β†’</span> </strong></p>
  84.             <div style="display:block; overflow:hidden;"> 
  85.                 <div style="width: 50%; float:left; display:inline-block">
  86.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  87.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  88.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  89.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  90.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  91.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  92.                     </ul>
  93.             </div>
  94.  
  95.             <div style="width: 50%; float:left; display:inline-block">
  96.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  97.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  98.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  99.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  100.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  101.                         <li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
  102.                     </ul>
  103.                 </div>
  104.                <div style="clear:both;"></div> 
  105.                <br/>
  106.                 <div class="youtubeIcon">
  107.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  108.                 </div>
  109.     </div>
  110.  
  111. </div>
  112.  
  113.   <!--End RelatedTopics Section-->
  114. </body>
  115. </html>

Step 2:- Create JavaScript File : multipleSliderScript.js

multipleSliderScript.js [JavaScript File]

  1.    $(document).ready(function(){
  2.    $('#sliderContainer').myhrSlider();
  3.    $('#sliderContainer1').myhrSlider();
  4.    $('#sliderContainer2').myhrSlider();
  5.  })
  6.  
  7. $.fn.myhrSlider = function()
  8. {
  9.  var thisObj = $(this);
  10.  var ulmain = thisObj.find('ul:first');    
  11.  var lisize = thisObj.find('li').size();
  12.  var liwidth = thisObj.find('li').outerWidth(true);    
  13.  ulmain.width(lisize*liwidth + 'px');
  14.  $('.pre').addClass('active');
  15.  
  16. var preLnk = thisObj.find('.pre');
  17. var nxtLnk = thisObj.find('.nxt');
  18.  
  19.  
  20.  var animation = true;
  21.  nxtLnk.click(function(event){
  22.      event.preventDefault();
  23. 	 if(lisize<4)
  24. 	 {
  25. 	   return false;
  26. 	 }
  27. 	 else
  28. 	 {
  29. 	   if(!$(this).is('.active'))
  30. 		{
  31. 		  if(animation)
  32. 		  {
  33. 			animation=false;
  34. 			ulmain.animate({left:'-='+ liwidth + 'px'}, 200, function(){
  35. 			  slideElement();
  36. 			})	
  37. 		  }
  38. 		}
  39. 	 }
  40.  
  41. 	return false;
  42.   })
  43.  
  44.  
  45.   preLnk.click(function(event){
  46.     event.preventDefault();
  47.     if(!$(this).is('.active'))
  48. 	{
  49. 	  if(animation)
  50. 	  {
  51. 	    animation=false;
  52. 	    ulmain.animate({left:'+='+ liwidth + 'px'}, 200, function(){
  53. 		  slideElement();
  54. 		})	
  55. 	  }
  56. 	}
  57. 	return false;
  58.   })
  59.  
  60.  
  61.  
  62.   function slideElement()
  63.   {
  64.    animation=true;
  65.    if(ulmain.css('left')==('-' + liwidth*(lisize-4) + 'px'))
  66.    {
  67.      preLnk.removeClass('active');
  68.      nxtLnk.hide();
  69.    }
  70.    else if(ulmain.css('left')=='0px')
  71.    {
  72.      nxtLnk.removeClass('active');
  73.      preLnk.hide();
  74.    }
  75.  
  76.    else
  77.    {
  78.      preLnk.show();
  79.      nxtLnk.show();
  80.    }
  81.   }
  82.  
  83.  }

Step 3:- Create Style CSS : multipleSliderStyle.css

multipleSliderStyle.css [Style CSS File]

  1.   #sliderContainer{ position:relative; width:473px; margin:auto; border:1px #ccc solid;}
  2.  #sliderContainer .over{ overflow:hidden; padding:5px;}
  3.  #sliderContainer .pre{ position:absolute; left:-30px; top:15%;}
  4.  #sliderContainer .pre{ color:#000000; text-decoration:none;}
  5.  #sliderContainer .pre:hover, .pre.active{ color:#FF0000; text-decoration:none;}
  6.  
  7.  #sliderContainer .nxt{ position:absolute; right:-30px; top:15%;}
  8.  #sliderContainer .nxt{ color:#000000; text-decoration:none;}
  9.  #sliderContainer .nxt:hover, .nxt.active{ color:#FF0000; text-decoration:none;}
  10.  
  11.  #sliderContainer ul.sliderList{ margin:0; padding:0; list-style:none; position:relative; }
  12.  #sliderContainer ul.sliderList li{ width:100px; height:90px; padding:3px; border:1px #ff0000 solid; float:left; margin-right:10px;} 
  13.  
  14.  #sliderContainer1{ position:relative; width:473px; margin:auto; border:1px #ccc solid;}
  15.  #sliderContainer1 .over{ overflow:hidden; padding:5px;}
  16.  #sliderContainer1 .pre{ position:absolute; left:-30px; top:15%;}
  17.  #sliderContainer1 .pre{ color:#000000; text-decoration:none;}
  18.  #sliderContainer1 .pre:hover, .pre.active{ color:#FF0000; text-decoration:none;}
  19.  
  20.  #sliderContainer1 .nxt{ position:absolute; right:-30px; top:15%;}
  21.  #sliderContainer1 .nxt{ color:#000000; text-decoration:none;}
  22.  #sliderContainer1 .nxt:hover, .nxt.active{ color:#FF0000; text-decoration:none;}
  23.  
  24.  #sliderContainer1 ul.sliderList{ margin:0; padding:0; list-style:none; position:relative; }
  25.  #sliderContainer1 ul.sliderList li{ width:100px; height:90px; padding:3px; border:1px #287d04 solid; float:left; margin-right:10px;}
  26.  
  27.  
  28.  #sliderContainer2{ position:relative; width:473px; margin:auto; border:1px #ccc solid;}
  29.  #sliderContainer2 .over{ overflow:hidden; padding:5px;}
  30.  #sliderContainer2 .pre{ position:absolute; left:-30px; top:15%;}
  31.  #sliderContainer2 .pre{ color:#000000; text-decoration:none;}
  32.  #sliderContainer2 .pre:hover, .pre.active{ color:#FF0000; text-decoration:none;}
  33.  
  34.  #sliderContainer2 .nxt{ position:absolute; right:-30px; top:15%;}
  35.  #sliderContainer2 .nxt{ color:#000000; text-decoration:none;}
  36.  #sliderContainer2 .nxt:hover, .nxt.active{ color:#FF0000; text-decoration:none;}
  37.  
  38.  #sliderContainer2 ul.sliderList{ margin:0; padding:0; list-style:none; position:relative; }
  39.  #sliderContainer2 ul.sliderList li{ width:100px; height:90px; padding:3px; border:1px #670323 solid; float:left; margin-right:10px;}

w3web.net -- multiple carousels on one page jquery

 

Further post that would you like to learn in Salesforce

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
   

 

 

 

FAQ (Frequently Asked Questions)

What is a product slider?

A product slider, or carousel, is a slideshow displaying product images and details for website visitors to scroll through. Product sliders allow you to showcase multiple products at once, feature related products, and make it easier for visitors to browse your online store.

What is featured slider in WordPress?

'WP Featured Content and Slider' is a clean and easy-to-use features showcase management system for WordPress. Display Featured Content/Featured services, features your product, company or services offers, and display them via a shortcode OR template code.

What is photo carousel?

Carousel ads are a kind of advertising format that combines multiple videos or images into a single ad. Carousel ads are most popular on Instagram and Facebook, where you can showcase a number of images to improve your chances of a conversion or sale.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses β†’

πŸ‘‰ Get Free Course β†’

πŸ“Œ Salesforce Administrators

πŸ“Œ Salesforce Lightning Flow Builder

πŸ“Œ Salesforce Record Trigger Flow Builder

πŸ‘‰ Get Free Course β†’

πŸ“Œ Aura Lightning Framework

πŸ“Œ Lightning Web Component (LWC)

πŸ“Œ Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment