Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery error

Posted on 2013-06-23
11
Medium Priority
?
467 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

824 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