如何用原型解释jQuery.noConflict()的简单例子?

时间:2010-04-28 13:23:06

标签: prototypejs jquery

如何使简单工作(仅当我删除/评论原型)示例解释带有原型的jQuery.noConflict()?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NO Conflict</title>
<link rel="stylesheet" href="hhttp://meyerweb.com/eric/tools/css/reset/reset.css" type="text/css"  media="screen, projection" /><link />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
//your javascript code
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"></script>
<!--[if lt IE 7]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta3)/IE7.js"></script>
<![endif]-->
</head>
<body>
    <!--Example of conflict-->
</body>
</html>

http://jsbin.com/imuze3/2

1 个答案:

答案 0 :(得分:1)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>NO Conflict</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    // Try decommenting the noConflict instruction to use prototype's $
    //$.noConflict();
    alert($('abc') == null);
    </script>
</head>
<body>
    <div id="abc"></div>
</body>
</html>