1

I am not familiar with JS at all and I was wondering how I can get this working in my Magento shop:

JSFiddle

I apologise in advance if this is a stupid question.

0

3 Answers 3

1

add the jquery library first then add your js code. also the $ variable is reserved for prototype in magento so you need to add noConflict()

<script>
jQuery.noConflict();
 jQuery('#product_pop_before').delay(3000).fadeOut('slow', function(){
        jQuery('#product_pop').fadeIn('slow');
    jQuery('#product_pop').delay(4000).fadeOut(),
        jQuery('#product_pop_before').delay(5000).fadeIn('slow');
    });
</script>
6
  • I get $.noConflict is not a function I added ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js Commented Jun 24, 2016 at 9:59
  • @MikeTimTurner did you add before this code or after? my mistake it is jQuery.noConflict(); Commented Jun 24, 2016 at 10:01
  • This is great. I can only get it to work with an Onload function. Is there anyway around this? Commented Jun 24, 2016 at 10:17
  • which function you want to execute this function? Commented Jun 24, 2016 at 10:20
  • Is it possible to run it without a function as I do not want to modify the <body> tag Commented Jun 24, 2016 at 10:23
0

Just insert the code in the template you need and wrap it in <script type="text/javascript"></script>

1
  • I've done that and also created a Onload function but when I inspect it shows this error: Uncaught TypeError: Cannot read property 'delay' of null Commented Jun 24, 2016 at 9:39
0

Use below code:

<script>
jQuery.noConflict();
 jQuery('#product_pop_before').delay(3000).fadeOut('slow', function(){
        jQuery('#product_pop').fadeIn('slow');
    jQuery('#product_pop').delay(4000).fadeOut(),
        jQuery('#product_pop_before').delay(5000).fadeIn('slow');
    });
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.