A
A
Alexander2012-06-09 20:03:20
JavaScript
Alexander, 2012-06-09 20:03:20

Why doesn't slide show jquery work?

Hello.

Is there a code for the slideshow?

function slideSwitch() {<br/>
 var $active = $('#slideshow DIV.active');<br/>
<br/>
if ( $active.length == 0 ) $active = $('#slideshow DIV:last');<br/>
<br/>
var $next = $active.next().length ? $active.next()<br/>
 : $('#slideshow DIV:first');<br/>
<br/>
$active.addClass('last-active');<br/>
<br/>
$next.css({opacity: 0.0})<br/>
 .addClass('active')<br/>
 .animate({opacity: 1.0}, 1000, function() {<br/>
 $active.removeClass('active last-active');<br/>
 });<br/>
}<br/>
<br/>
$(function() {<br/>
 setInterval( &quot;slideSwitch()&quot;, 5000 );<br/>
});<br/>


And inserting the slideshow itself
&lt;-div id=&quot;slideshow&quot; align=&quot;center&quot;&gt;<br/>
 &lt;-div class=&quot;active&quot;&gt;<br/>
 &lt;-a href=&quot;/test1.html&quot;&gt;&lt;-img src=&quot;/images/images1.jpg&quot; alt=&quot;&quot; class=&quot;active&quot; /&gt;&lt;-/a&gt;<br/>
 &lt;-/div&gt;<br/>
 &lt;-div&gt;<br/>
 &lt;-a href=&quot;/test2.html&quot;&gt;&lt;-img src=&quot;/images/images2.jpg&quot; alt=&quot;&quot; /&gt;&lt;-/a&gt;<br/>
 &lt;-/div&gt;<br/>
&lt;-/div&gt;<br/>


The problem is that the jquery-1.6.2.min.js engine itself (but the file is simply called jquery.js) is already included. But the code doesn't work that way. But if you insert before the script code of the slideshow

&lt;-script type=&quot;text/javascript&quot; src=&quot;/js/jquery-1.6.2.min.js&quot;&gt;&lt;-/script&gt;&quot;


The slideshow starts working.

The question is why the slideshow does not work if you do not insert a jquery connection before the slideshow script?

PS I checked that the jquery file in the engine and the jquery-1.6.2.min.js file downloaded from the jquery site are identical

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaliy Petrychuk, 2012-06-09
@vermilion1

Is this jquery.js connected by any chance after the Slide Show?
Give an example page or copy errors from the console if any.
PS cache the elements

setInterval( "slideSwitch()", 5000 ); // и никогда так не делайте 
setInterval(slideSwitch, 5000 ); // вот так намного лучше

A
Alexander, 2012-06-09
@baltazorbest

jquery connects after, error in Web Console
$active is null

A
Alexander, 2012-06-09
@baltazorbest

In general, I localized the problem to the point that jquery and mootools are not compatible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question