I generally use this in jquery
$(document).ready(function() {
//stuff
}
I was just on a site that heavily uses jquery and they call it using
$j(document).ready(function() {
//stuff
}
On this site they start almost everything out with a j...
function PostComment(form) {
form = $j(form);
$j('#CommentSubmitButton').hide();
$j('#CommentInProgress').show();
$j.post('/utils/ajaxhandler.aspx', form.serialize(), function(data) {
$j('#CommentInProgress').hide();
$j('#CommentSubmitButton').show();
});
}
Is this just another way of doing it or is this dependent on a differnt version of jquery or other?
The $ represents the jQuery Function, and is actually a shorthand alias for jQuery .
noConflict() method to give control of the $ variable back to whichever library first implemented it. This helps us to make sure that jQuery doesn't conflict with the $ object of other libraries. // Import other Library // Import jQuery Library $. noConflict(); // Code that uses other library's $ can follow here.
In jQuery, the $ sign is just an alias to jQuery() , then an alias for a function. This page reports: Basic syntax is: $(selector).action() A dollar sign to define jQuery. A (selector) to "query (or find)" HTML elements.
Definition and Usage The noConflict() method releases jQuery's control of the $ variable. This method can also be used to specify a new custom name for the jQuery variable. Tip: This method is useful when other JavaScript libraries use the $ for their functions.
You can define, how you want to call the jquery functionality. Maybe this site uses another library, which reserves the $, and for that reason used the alias $j.
This is to avoid colision with other libraries with:
jQuery.noConflict();
For instance some libraries like prototype also use the $ sign, and if you end up using both it will most likely break. If you developed your jquery functions using $j it won't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With