Two jQuery plugin conflicting on the same page

2019-09-05 12:05发布

I have two jQuery Plugins working on the same file. One is jquery.autocomplete.js and the other is jquery.thumbnailScroller.js .

The problem is when I am using both on same file, autocomplete is not working at all an thumbnailScroller is working and but the same is working well without thumbnailScroller plugin.

Now, when I was browsing thru the js files, I got $.fn. in both files. But, I dont know is the problem because of this or anything else.

I had searched in google and stackoverflow also, but I failed to get the proper solution. Please guide me

1条回答
相关推荐>>
2楼-- · 2019-09-05 12:31

There are some ways for avoiding conflict in jquery. I always do like this

var $k = jQuery.noConflict();

and use $k for every $ functions for any one plugin. Not do this in plugin js files. Do this for your implementation page, like,

$k("#id").autocomplete({... 

Regards

iijb

查看更多
登录 后发表回答