Uncaught TypeError: undefined is not a function in

2019-06-02 23:26发布

问题:

I've this error in my own J template, where jquery is linked by script tag.

Error occurres in this script:

$(document).ready(function(){
    $('.login-dropdown').click(function() { //this passes (tested with alert)
        $('.login-container').show(); // there is error
    });
});

for record - .login-container has display:none which could by right for show() method.

I suspect the conflict between jquery and joomla, but do not know how to deal with it eventually.

Thank for any help.

回答1:

Joomla uses mootools, so there might be conflict between them.

Use $.noConflict():

jQuery.noConflict();
jQuery(document).ready(function($){
    $('.login-dropdown').click(function() { //this passes (tested with alert)
        $('.login-container').show(); // there is error
    });
});


标签: jquery joomla