문제

I have two JavaScript files that contain a jQuery function with the same name $().

How can I distinguish between the two identically named functions?

도움이 되었습니까?

해결책

Rename one.

$ = typeof $ !== 'function' ? $ : $foo;

다른 팁

Short answer: You can't. All includes js files live in the same namespace.

Perhaps you want Using jQuery with Other Libraries, but I can't tell exactly what your problem is from the question. Perhaps you could include some sample code of the problem you're having?

Try using a namespace for each project you work on. For instance, instead of writing a function called dosomething(), call it myproject.dosomething()

That way, it is project specific and you will avoid having two identically named functions, even if you are including files you did not develop yourself.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top