views:

303

answers:

1

How to make simple working (only if i remove/comment prototype) example to explain jQuery.noConflict() with prototype?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<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"&gt;&lt;/script&gt;
<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"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"&gt;&lt;/script&gt;
<!--[if lt IE 7]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta3)/IE7.js"&gt;&lt;/script&gt;
<![endif]-->
</head>
<body>
    <!--Example of conflict-->
</body>
</html>

http://jsbin.com/imuze3/2

A: 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<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"&gt;&lt;/script&gt;
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
    <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>
Darin Dimitrov