Note that there are some explanatory texts on larger screens.

plurals
  1. PORun one Jquery Script independently for each <div>
    primarykey
    data
    text
    <p>I have the following question:</p> <p>I am working on a JQuery script that turns some HTML into a "Slider". No problem so far, everything's working smoothly.</p> <p>The thing is is, if I want to run two or more "sliders" at the same time, of course they all "act" the same.</p> <p>If I want them to act differently at the same time, can I "add" the script several times in the HTML-Code (, or do I have to add a ".each()" function, to the script?</p> <p>HTML-Code:</p> <pre><code>&lt;div id="galleria1" interval="1000"&gt; &lt;a href="#" class="show" &gt; &lt;img width="640" height="450" rel="Slider-Image"src="a.jpg" /&gt; &lt;/a&gt; ... &lt;/div&gt; &lt;div id="galleria2" interval="1000"&gt; &lt;a href="#" class="show" &gt; &lt;img width="640" height="450" rel="Slider-Image"src="b.jpg" /&gt; &lt;/a&gt; ... &lt;/div&gt; </code></pre> <p>Would be cool of any of you knows a solution to this!</p> <p>Thanks, Mario.</p> <p>EDIT:</p> <p>Here the Script:</p> <pre><code>$(document).ready(function() { //checks if page is completely loaded slideshow(); }); function slideshow() { //Sets all pictures opacity to 0 $('#galleria a').css({opacity:0.0}); //Sets the first picture's opacity to 1 $('#galleria a:first').css({opacity:1.0}); //Calls the gallery() function to run the slideshow, number gives time till next 'slide' im milliseconds setInterval('nextPicture()', 1000); } function nextPicture() { //If no image hast the class 'show', takes the first picture var current = ($('#galleria a.show')? $('#galleria a.show') : $('#galleria a:first')); //Get next image, if reached the end of slideshow, starts from the begining var next = ((current.next().length == 0) ? $('#galleria a:first') : current.next()); //Runs Animation and makes next picture visible, number gives fade in time next.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, 1000); //Hides last picture current.animate({opacity: 0.0},1000) .removeClass('show'); } </code></pre> <p>-> used the same id="galleria" for both so far. (already changed this in the html above)</p> <p>Thanks for the answers so far!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload