Solved

jquery error

Posted on 2013-06-23
11
461 Views
Last Modified: 2013-06-23
Hello,

I have a jquery error and I can not figure it out. It works on all browsers but not IE, it is driving me nuts.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
    $('.fadein a:gt(0)').hide();
    setInterval(function(){
      $('.fadein a:first-child').fadeOut()
         .next('a').fadeIn()
         .end().appendTo('.fadein');},
      3000);
});
</script>

page http://tinyurl.com/6rdkqoa
0
Comment
Question by:movieprodw
  • 7
  • 3
11 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39269867
Why are you including two version of jquery?
One in the head and one just before the script
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269878
Well if I only include the one in the head the it doesn't work on any browser
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269893
I deleted the second jquery and you can see the slideshow does not load now
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 16

Expert Comment

by:hankknight
ID: 39269932
This works:
<script type="text/javascript">
function HomeFade() {
 jQuery('.fadein a').show();
 jQuery('.fadein a').last().fadeOut(350, function() {
    jQuery('.fadein a').last().prependTo(jQuery('.fadein'));
 });
}

jQuery(document).ready(function () {
    setInterval("HomeFade()",3000);
});
</script>

Open in new window

0
 
LVL 16

Expert Comment

by:hankknight
ID: 39269938
You should use:
jQuery(function(){

Open in new window

instead of
$(function(){

Open in new window

because you are also using prototype.js and there is a conflict with the "$" symbol.  I also made slight changes to the logic of your script.
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269939
I have ditched the second script and edited the script to be scriptlicious not jquery and it works in all browsers but in IE it does not fade.

Any idea?

<style type="text/css">
.fadein { position:relative; height:332px; width:500px; }
.fadein img { position:absolute; left:0; top:0; }
.fadein a {display:block;}
</style>
<script>
setInterval(function(){
  var as = $$('.fadein a'),
   visible = as.findAll(function(a){ return a.visible(); });
  if(visible.length>1) visible.last().fade({ duration: .3 });
    else as.last().appear({ duration: .3,
      afterFinish: function(){ as.slice(0,as.length-1).invoke('show');  } });
}, 3000);
</script>
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269942
Thank you! That worked, can you please help me make it so they are ordering opposite, for some reason your script made them load the last first.
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269948
This fixed the fade issue FYI

"Apparently there's a workaround!

Simply set the absolute/relative positioned elements the following css attributes:

opacity:inherit;
filter:inherit;"
0
 
LVL 1

Author Comment

by:movieprodw
ID: 39269957
I can just order them backwards.

The only issue I have is that it is not hiding the non active images, it flips through them on load and when you leave the page then go back.

Thank you for your help,
Matt
0
 
LVL 16

Accepted Solution

by:
hankknight earned 500 total points
ID: 39269983
This should address all the issues you raised:
<script type="text/javascript">
function HomeFade() {
 jQuery('.fadein a').css('opacity',1).css('zIndex','1');
 jQuery('.fadein a:eq(1)').css('zIndex','2');
 jQuery('.fadein a').show().first().css('zIndex','3').animate({
    opacity: 0,
  }, 500, function() {
    jQuery('.fadein a').first().appendTo(jQuery('.fadein'));
  });
}

jQuery(document).ready(function () {
  jQuery('.fadein a').hide();
  jQuery('.fadein a img').hide();
  jQuery('.fadein a img:eq(0)').attr('src', jQuery('.fadein a img:eq(0)').attr('src')).load(function() {
   jQuery('.fadein a img').show();
   jQuery('.fadein a').show().css('zIndex','1').css('position','absolute');
   jQuery('.fadein a').first().css('zIndex','3');
   setInterval("HomeFade()",4000);
  });
});
</script>

Open in new window

0
 
LVL 1

Author Closing Comment

by:movieprodw
ID: 39269987
Thank you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question