8

I did heavy use of jquery on my php project. But on some page the $ is not working, so I have to use jquery. For example:

jQuery('#mycarousel').jcarousel({
start: 3
});

Can anybody please tell me what is the difference between $ and jquery?

0

8 Answers 8

11

when .noConflict() is called, selector like $('') is no longer working to ensure compatibility with other framework such as Prototype. at that time jQuery('') is used instead.

Reference: jQuery.noConflict()

To better illustrate the idea, here is an example obtained from the reference link:

<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>
3

$ is just a variable that is used to alias jQuery and it is a varible so anything could be assigned to it.

You can get detailed information related to it from its Documentation

2

The simplest possible console experiment which isslustrates what has already been told:

($ === jQuery); //true
$.noConflict();
($ === jQuery); //false
1

The $ represents the jQuery Function, and is an alias for jQuery

0

these are same except $ is ShortForm of Jquery in Jquery

2
  • 1
    @XTG, incorrect, in no conflict mode, $ is not acting as short form of jQuery
    – Raptor
    Mar 26, 2013 at 7:27
  • this may help css-plus.com/2010/03/…
    – XTGX
    Mar 26, 2013 at 7:28
0

It's a jquery conflict. You should use a correct jquery plugin to solve this problem. use a latest Jquery plugin and remove the old one from your code.

0

$ is an alias of jQuery in old version.

In latest version if you're using this $ then that function will not execute.

So, no need to change the entire code with jQuery...

before that code, put:

var $ = jQuery; 

very simple...

-3
$.ajax({
    url: 'Emp.asmx/getDesignation',
    type:'post',
    contentType: 'application/json;charset=utf-8',
    dataType: 'json',
    data: "{}",
    aync: false,
1
  • 6
    Can you please add some explanation as to how this answers the question? It appears to me to be completely irrelevant
    – Rob
    Jan 9, 2018 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.