$
.
If other frameworks also use $ as shortcode, the script will not work. To avoid this, jQuery team implemented noConflict() method. jQuery
instead of shortcut $.
[html]
<html>
<head>
<title>jQuery noConflict()</title>
</head>
<body>
<h1>Welcome to SPLessons</h1>
<div>
<p>click on this paragraph</p>
</div>
</body>
</html>
[/html]
[javascript]
$.noConflict();
jQuery(document).ready(function()
{
jQuery("p").click(function()
{
alert("Paragraph was clicked");
}
}
[/javascript]
Output:
jQuery
utilizing $, inside this function - outside of it, and need to utilize "jQuery":
[html]
<html>
<head>
<title>jQuery noConflict()</title>
</head>
<body>
<h1>Welcome to SPLessons</h1>
<div>
<p>click on this paragraph</p>
</div>
</body>
</html>
[/html]
[javascript]
$.noConflict();
jQuery(document).ready(function($) {
$("p").click(function() {
alert("Paragraph was clicked");
});
});
[/javascript]
Output: