In jQuery some time '$' making trouble, what is the basic reason ? Answer in detail.
Thanks in Advance
jQuery(function () {
$("#tabs").tabs();
});
jQuery(function () {
jQuery("#tabs").tabs();
});
In jQuery some time '$' making trouble, what is the basic reason ? Answer in detail.
Thanks in Advance
jQuery(function () {
$("#tabs").tabs();
});
jQuery(function () {
jQuery("#tabs").tabs();
});
its because other library also use $
so there will be conflict use jQuery.noConflict()
jQuery.noConflict();
(function($) {
$(function() {
// more code using $ as alias to jQuery
});
})(jQuery);
or like
<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
</script>
You might have another library which also makes use of $
.
In which case you can make use of jQuery.noConflict.()
var j = jQuery.noConflict();
j(function () {
j("#tabs").tabs();
});
The reason might be conflict with other plugins like prototype for example that also uses the $ sign
The basic reason is that the $
variable is also used by others javascript framework like Prototypejs and Mootools.
So if you want to use both jQuery and Mootools for instance, you should avoid the use of $
.