Simple Jquery Slider

Size
2,430 Kb
Views
12,144

How do I make an simple jquery slider?

Inspired in http://rafbm.github.io/howtomakeaslider/. What is a simple jquery slider? How do you make a simple jquery slider? This script and codes were developed by Hélio Marcondes on 13 November 2022, Sunday.

Simple Jquery Slider Previews

Simple Jquery Slider - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Jquery Slider</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script>
</script> <div class="slider"> <ul> <li><p>Testing "caption"</p><img src="https://wallpaper.ultradownloads.com.br/143484_Papel-de-Parede-Bandeira-de-Portugal_1280x720.jpg"></li> <li><p>Testing "caption2"</p><img src="https://wallpaper.ultradownloads.com.br/143987_Papel-de-Parede-Bandeira-Suja-da-Jamaica_1280x720.jpg"></li> <li><p>Testing "caption3"</p><img src="https://wallpaper.ultradownloads.com.br/144871_Papel-de-Parede-Bandeira-da-Suecia_1280x800.jpg"></li> </ul>
</div>
<a style="position:absolute;top:0;" href="javascript:sliders[0].goToPrev()">.goToPrev()</a>
<a style="position:absolute;top:30px;" href="javascript:sliders[0].goToNext()">.goToNext()</a> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Simple Jquery Slider - Script Codes CSS Codes

*{ box-sizing:border-box;
}
.slider{ width:400px; height:300px; margin:0 auto; overflow:hidden;
}
.slider > ul{ position: relative; -webkit-transition: 0.5s left; list-style: none; margin: 0; padding: 0;
}
.slider > ul > li { float: left; width: 400px; height: 300px; }
button{ position:absolute; top:100px; left:10px;
}
p{ color:white; background:black; width:100%; border:1px solid red; position:absolute; top:250px; height:30px; opacity:0.8;
}

Simple Jquery Slider - Script Codes JS Codes

var Slider = function() { this.initialize.apply(this, arguments) } Slider.prototype = { initialize: function(slider) { this.ul = slider.children[0] //take first ul this.li = this.ul.children //take first li // make <ul> as large as all <li>’s this.ul.style.width = (this.li[0].clientWidth * this.li.length) + 'px' this.currentIndex = 0 }, goTo: function(index) { // filter invalid indices if (index < 0 || index > this.li.length - 1) return // move <ul> left this.ul.style.left = '-' + (100 * index) + '%' this.currentIndex = index }, goToPrev: function() { this.goTo(this.currentIndex - 1) }, goToNext: function() { this.goTo(this.currentIndex + 1) } } var sliders = [] $('.slider').each(function() { sliders.push(new Slider(this)) })
Simple Jquery Slider - Script Codes
Simple Jquery Slider - Script Codes
Home Page Home
Developer Hélio Marcondes
Username haykou
Uploaded November 13, 2022
Rating 3
Size 2,430 Kb
Views 12,144
Do you need developer help for Simple Jquery Slider?

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!

Hélio Marcondes (haykou) 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!