Why does it make a difference where I include the jQuery script file?

Posted by Matthew Jones on Stack Overflow See other posts from Stack Overflow or by Matthew Jones
Published on 2010-05-11T17:50:05Z Indexed on 2010/05/11 17:54 UTC
Read the original article Hit count: 314

On my master page (for all pages in my site) I have a ToolkitScriptManager.

On my content page, there are a series of hyperlinks and divs for collapsible functionality.

The code to show/hide the panels work like the following:

$('#nameHyperLink').click(function() {

        var div = $('#nameDiv');
        var link = $('#nameHyperLink');
        if (div.css('display') == 'none') {
            link.text('Hide Data');
            div.show('100');
        }
        else {
            link.text('Show Data');
            div.hide('100');
        }

    });

If I include a ScriptReference to the jQuery 1.4.2 file in the toolkitscriptmanager, the javascript code is executed incorrectly on the page (only the text for the hyperlink is changed, the div is not actually shown.) However, if I don't include the jQuery file in the ToolkitScriptManager and instead include it in the content page, it works correctly.

I'm a Javascript/jQuery newbie, and this makes no sense at all. What's going on here?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about toolkitscriptmanager