1

I've some libraries on my website, that are using $ as variable/function. I made them separate with :

jQuery(document).ready(function ($) {
    codeThatWillUseJquery($);
});

but in fact, I think there are somethings wrong. in fact :

function codeThatWillUseJquery($)
{
    console.log($('#myId').index());
}

it returns always -1, on every element. So I think there is some incompatibility in the code.

How can I know if $('#myId').index() call the jQuery's .index() function? Is there a way?

4

1 に答える 1

2

あなたが使用する必要がありますobj instanceof jQuery

これを確認してくださいオブジェクトがjQueryオブジェクトかどうかを確認してください

于 2012-10-04T07:52:32.457 に答える