什么是jquery noConflict,我们为什么需要它? [英] what is jquery noConflict, why do we need that?

查看:128
本文介绍了什么是jquery noConflict,我们为什么需要它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了一个包含jQuery.noConflict方法的jquery代码.

i have seen a jquery code that contains jQuery.noConflict method.

不知道它的目的,没有得到我们为什么需要它的原因.

do not know purpose of it, didnt get the why we need that.

我只知道这与jquery插件有关.

i only understand that it is something related to jquery plugin.

推荐答案

jQuery(和其他类似的框架)将jQuery对象的别名存储在$变量中.只是为了简化代码编写时的速记.

jQuery (and other frameworks like it) store an alias of the jQuery object in the $ variable. It's just for easy shorthand when you write code.

实际上,您可以像这样编写所有代码jQuery('.selector');,而不愿意使用美元符号.无冲突模式允许您使用其他代码(通常是另一个框架),也可以将某些内容存储在美元符号变量中.

You could actually write all your code like this jQuery('.selector'); instead of using the dollar sign if you wanted to. The no-conflict mode allows you to use other code (usually another framework) that ALSO stores something in the dollar sign variable.

这篇关于什么是jquery noConflict,我们为什么需要它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆