Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between $ and jQuery

Tags:

When I try to use $("#div_id") in $(document).ready it returns NULL, but when I use jQuery("#div_id") it returns the actual object!

Why is that happening?

UPDATE: I tried noConflict method without gaining any hints.

jQuery.noConflict() function (a,b){return new c.fn.init(a,b)}  $.noConflict(); TypeError: Object function ()     {         return document.getElementById.apply(document, arguments)     } has no method 'noConflict' 

UPDATE 2:

$(document).ready(function() {     debugger; });  <input type="text" id="test" name="test" value="123" /> 

When I run the following code in the console i got those results:

$("#test").val() TypeError: Cannot call method 'val' of null jQuery("#test").val() "123" 

Thanks

like image 515
wael34218 Avatar asked Jun 07 '11 07:06

wael34218


People also ask

What is difference between jQuery and JS?

JavaScript is a programming language. jQuery is an Application Programming Interface (API). JavaScript boosts up the execution of a program and saves the time required for connecting to the server. It provides numerous interfaces to developers for creating catchy web pages.

Which is best jQuery or JavaScript?

Though JavaScript is the basic language from which jQuery has evolved, jQuery makes event handling, DOM manipulation, Ajax calls much easier than JavaScript. jQuery also allows us to add animated effects on our web page which takes a lot of pain and lines of code with JavaScript.

What is $() in jQuery library?

$() = window. jQuery() $()/jQuery() is a selector function that selects DOM elements. Most of the time you will need to start with $() function. It is advisable to use jQuery after DOM is loaded fully.

What does hashtag mean in jQuery?

The hash (#) specifies to select elements by their ID's. The dot (.) specifies to select elements by their classname. You can read more about the selectors here: http://api.jquery.com/category/selectors/basic-css-selectors/


1 Answers

See jQuery.noConflict(). Could other javascript libraries on your page be using the $ variable?

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

like image 52
Graham Avatar answered Dec 17 '22 03:12

Graham