jQuery.noConflict();
function just before jQuery(document).ready ( function () { })
and replace jQuery
at all instance of $
but i have seen many jQuery plugin where $
is used with variable declaration???
here is an example on this link on below section
How to...
[edit]
...retrieve the index of the currently selected tab
var $tabs = $('#example').tabs();
var selected = $tabs.tabs('option', 'selected'); // => 0
now i m really c开发者_运维技巧onfused how to replace $
with jQuery
in var $tabs
??
first of all tell me how can we use jQuery
instead of $
in above example and
what is the logic behind declaring variable starting with $
in javascript?? ( although this is a PHP varaible decalarion syntax)
Thank you.
$tabs
is just a variable name. That's because javascript accepts a $
as part of a variable.
You can also use variables like my$var = 10
or my$other$var$ = 20
.
To use jQuery
instead of $
just substitute it in your code:
var x = $('#mydiv')
becomes
var x = jQuery('#mydiv')
JavaScript variable names start with a letter, $, or underscore.
http://javascript.about.com/od/variablesandoperators/a/vop04.htm
so $tabs is a normal variable and has nothing to do with jQuery.
Like javascript many other languages allow usage of $ in variable names.
You can refer this answer why does several javascript libraries use $ for one or other use for wonderful explanation of why $ is used in javascript or jQuery.
精彩评论