Solved

jquery error

Posted on 2013-06-23
11
458 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery to restrict certain words from input in form 11 34
how can i count words? 2 40
PHP AJAX Wordpress 9 19
Question about JQuery and asp.net 3 23
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
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)

815 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

12 Experts available now in Live!

Get 1:1 Help Now