I've some second thoughts and I'm a bit confused on this code: this line of code is the one that I'm wondering about :
var items = $("#" + element[0].id + " li");
Now my question is: how does this line of code work? so where is the magic here? is it populating the items-array?
Thanks by the way!
Is it jquery doing this in one move when we target the < ul > - element? (with this code:
$(document).ready(function() {
$("#slider").mySlider({
timeOut: 4000,
captionOpacity: .7
});
here is some part of the code, the part that I'm wondering about: let's say u have this html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="js/mySlider.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#slider").mySlider({
timeOut: 4000,
captionOpacity: .7
});
});
</script>
<title></title>
</head>
<body>
<ul id="slider">
<li>
<img src="img/image1.jpg" alt="" />
<div class="top">
Some nice text captions..
</div>
</li>
<li>
<img src="img/image2.jpg" alt="" />
<div class="bottom">
Some nice text captions..
</div>
</li>
</ul>
</body>
</html>
and here the JS:
$.fn.mySlider = function(vars) {
var timeOut = vars.timeOut || 4000;
var capOpacity = vars.captionOpacity || .7;
var element = this;
var fxDuration = timeOut/6;
var items = $("#" + element[0].id + " li"); //how do add the < li > items inside this array?
var captions = $("#" + element[0].id + " li div");
// console.log(items);
items.css('display','none');
captions.css({
'opacity': capOpacity,
'display': 'none'
});