xiatica
xiatica

Reputation: 1576

jquery latest conflict, having difficulty troubleshooting

Hello All and thanks ahead for any help

I'm working on a website which references a global template that calls jquery-latest-min.js

So before you ask, the version will change beyond my control.

After many hours of troubleshooting some jquery code, I've found that removing the call for jquery latest will make the code work again, however when it's broken, the following code doesn't return the correct option index. If you remove jquery latest, it works.

<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="jquery-latest-min.js"></script> <!-- THIS IS THE ONE CAUSING CONFLICT -->
<script type="text/javascript">
    $(function() {
        $("div.click").click(function(){
            selectedOptionIndex = $("#mySelect option:selected").index();
            alert(selectedOptionIndex); // should alert "0"
        });
    });
</script>
</head>
<body>
    <select id="mySelect">
        <option value="">0</option>
        <option value="">1</option>
        <option value="">2</option>
        <option value="">3</option>
    </select>
    <div class="click">
        Click
    </div>
</body>
</html>

Is there something I'm doing wrong, or is there a problem with jquery latest? The version in particular here is v1.3.2

Upvotes: 0

Views: 621

Answers (1)

Emmanuel
Emmanuel

Reputation: 5395

You're including two versions of jQuery, that's probbaly causing the conflicts.

<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="jquery-latest-min.js"></script>

You only need one. So try removing the jquery-1.4.4.min.js.

Upvotes: 2

Related Questions