Jquery隔离 [英] Jquery Isolation

查看:59
本文介绍了Jquery隔离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司有一个网页应用程序,里面有一个普通的javascript,它以自己的方式使用$ - 美元符号,如下所示:

My company has a web application that has a plain javascript in it, and it use $ -"dollar symbol" in it's own way as shown:

function $(e) {
    return document.getElementById(e);
}

问题是当我将jquery嵌入页面时发生冲突。
有没有办法可以隔离jquery示例:

The problem is when I embed the jquery to the page there is a conflict occurs. Is there a way that I can isolate the jquery example:

$$(这) - 是调用jquery

$(这) - 给老员工打电话

$$(this) - is to call jquery and $(this) - to call old staff

请帮帮我谢谢

推荐答案

确保先包含你的lib,然后调用

Just make sure you include your lib first, then call

$.noConflict();
var $$ = jQuery;

这会将 $ 恢复到它的用途在解析jQuery之前,使 $$ 指向 jQuery http://api.jquery.com/jQuery.noConflict/

That will restore $ to what it used to be before jQuery was parsed and make $$ point to jQuery http://api.jquery.com/jQuery.noConflict/

这篇关于Jquery隔离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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