Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom jQuery slider for html elements not working
    primarykey
    data
    text
    <p>I'm trying to add a slider to animate some paragraphs at my home screen. I don't want to use any plugin. I want to create it myself using jQuery. But there is a problem, it seems that condition in jQuery is not working.</p> <p>Please checkout following codes and try to fix it.</p> <pre><code>&lt;div id="slider-viewport"&gt; &lt;div class="slider"&gt; &lt;p&gt;1 Cloud based e-commerce solution for your downloadable products&lt;/p&gt; &lt;p&gt;2 Cloud based e-commerce solution for your downloadable products&lt;/p&gt; &lt;p&gt;3 Cloud based e-commerce solution for your downloadable products&lt;/p&gt; &lt;p&gt;4 Cloud based e-commerce solution for your downloadable products&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>.slider p { font-size: 25px; color: #fff; height: 100px; margin: 0; } #slider-viewport { width: 100%; height: 100px; overflow: hidden; background-color: black; } .slider { width: 100%; height: auto; } </code></pre> <p>jQuery</p> <pre><code>$(document).ready(function() { $('.slider p').first().clone().appendTo('#slider-viewport .slider') function slider() { var $slider = $('#slider-viewport .slider'); var currentMargin = $slider.css('margin-top'); var paraHeight = $('.slider p').height(); var setMargin = parseInt(currentMargin) - paraHeight; var resetMargin = -300; if (currentMargin &lt; resetMargin) { $slider.css('margin-top', 0); }; $slider.animate({ marginTop: setMargin }, { duration: 600, easing: "easeOutQuint" } ); }; setInterval(slider, 3000); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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