1

I'm trying to run two different scripts, but only one will work at a time. If Code 1 and 2 are on the same page only one works. How can I make them work on the same page?

Code 1

<script src="lib/jquery-1.5.2.min.js"></script>
<script src="lib/jquery.peelback.js"></script>  
<script>
$(function() {
  $('body').peelback({
    adImage  : 'images/peel-ad.png',
    peelImage  : 'images/peel-image.png',
    clickURL : 'http://www.thebestdinosaur.com/',
    smallSize: 150,
    bigSize: 500,
    gaTrack  : true,
    gaLabel  : '#1 Stegosaurus',
    autoAnimate: true
  });
});
</script>

Code 2

<script src="lib/jquery.min.js" type="text/javascript"></script>
<script src="lib/jquery.nivo.slider.pack.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
2

1 Answer 1

1

You can use jQuery.noconflict, so replace your first code with:

<script src="lib/jquery-1.5.2.min.js"></script>
<script src="lib/jquery.peelback.js"></script>  
<script>
var jq152 = jQuery.noConflict(true);
jq152(function($) {
    $('body').peelback({
        adImage: 'images/peel-ad.png',
        peelImage: 'images/peel-image.png',
        clickURL: 'http://www.thebestdinosaur.com/',
        smallSize: 150,
        bigSize: 500,
        gaTrack: true,
        gaLabel: '#1 Stegosaurus',
        autoAnimate: true
    });
});
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

You removed the the ready callback (intentionally?). Just do jq152(function($) { ... });.
Felix, your code works perfect in IE, but in Firefox only the nivo.slider works. Any ideas? View wjfd.org
@user196815 Not sure why but your site works perfect for me in Firefox and Chrome. Try to clear your browser cache.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.