1

I am using one java script and one jquery in my html file in head tag, but my problem both the scripts are not working, i have used one slide show script and one nav menu script, in this both only one is working , is there any specific order to write these scripts , please find the below script order i have used , i am getting only slideshow. please help me out .

<script type="text/javascript">        google.load("mootools", "1.2.1");</script>
<script type="text/javascript" src="Js/MenuMatic_0.68.3.js" type="text/javascript"
    charset="utf-8">  </script>
<script type="text/javascript">
    window.addEvent('domready', function () {
        var myMenu = new MenuMatic();
    });</script>
<script type="text/javascript" src="Js/jquery.min.js"></script>
<script type="text/javascript" src="Js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="Js/slides.min.jquery.js"></script>
<script type="text/javascript">

    $(function () {
        $('#slides').slides({
            preload: true,
            preloadImage: 'img/loading.gif',
            play: 5000,
            pause: 2500,
            hoverPause: true
        });
    });

</script>
5
  • one java script and one jquery? There is conflict in your page. You can use jQuery noConflict method. Commented Aug 23, 2012 at 4:47
  • 4
    this may help you.. conflict is coz of using mootools and jquery together Commented Aug 23, 2012 at 4:48
  • If you're including jQuery on your page anyway, why don't you use its cross-browser compatible jQuery(document).ready(...) rather than window.addEvent('domready',...? Commented Aug 23, 2012 at 5:46
  • I have used what u said jQuery(document).ready(function ($){var myMenu= new MenuMatic(); .. but no use ... Commented Aug 23, 2012 at 6:03
  • thanx guys i found the solution ... Commented Aug 23, 2012 at 6:19

1 Answer 1

2

It looks like you have MooTools and jQuery loading on the same page which will work but you will have to replace the short hand jQuery function. jQuery uses $(function) shorthand for jQuery(function) and that shorthand notation could cause problems.

You will need to use the jQuery.noConflict() function anywhere jquery and it's plugins were using the $.

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

<script type="text/javascript">

    var $j = jQuery.noConflict();

    $j(function () {
        $j('#slides').slides({
            preload: true,
            preloadImage: 'img/loading.gif',
            play: 5000,
            pause: 2500,
            hoverPause: true
        });
    });

</script>
Sign up to request clarification or add additional context in comments.

2 Comments

Hi., can u please show, how can i write the noconflict method to above two functions what i have written in my code, because i am new to javascript .
I updated my answer to show you how it would work in the code snippet you provided.

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.