在 $ 的声明下方。是一个 javascript 变量吗?
我了解如何使用 $ 作为选择器
$('#Text').click(function () {
$('#Text').css('color', 'red')
});
但是当我声明变量时,我习惯于将其声明为 var x = function(){}...
此符号表示“$”的含义。是声明变量的 jquery 方式吗?
$.searchTwitter= function(){
$.ajax({
url:"http://search.twitter.com/search.json",
data:{
q:'dogs'
},
dataType:'jsonp',
success:function(results){
console.log(results);
}
});
};
$.searchTwitter();
最佳答案
在jQuery中,$
是jQuery
的别名。
即
$.ajax();
与 jQuery.ajax();
在 Javascript 中,$
没什么特别的;只是一个有效的 JavaScript 标识符。
引用:https://learn.jquery.com/about-jquery/how-jquery-works/
Note: The jQuery library exposes its methods and properties via two properties of the window object called jQuery and $. $ is simply an alias for jQuery and it's often employed because it's shorter and faster to write.
关于javascript - 使用 $ 的变量声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36112191/