Solved

jquery error

Posted on 2013-06-23
11
456 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now