Could anybody give me an explanation of the underscore in a jQuery plugin function? I have no idea of what "_" means. Example code below:
$.fn.bgStretch=function(o){
this.each(function(){
var th=$(this),
data=th.data('bgStretch'),
_={
align:'leftTop',
altCSS:{},
css:{
leftTop:{
left:0,
right:'auto',
top:0,
bottom:'auto'
},
rightTop:{
left:'auto',
right:0,
top:0,
bottom:'auto'
},
leftBottom:{
left:0,
right:'auto',
top:'auto',
bottom:0
},
rightBottom:{
left:'auto',
right:0,
top:'auto',
bottom:0
}
},
preFu:function(){
_.img
.load(function(){
_.checkWidthFu()
_.img
Just as lanzz commented. This is a variable.
Look at how the varaiables are declared:
var th=$(this),
data=th.data('bgStretch'),
_={..}
Another way to it is:
var th=$(this);
var data = th.data('bgStretch');
var _ ={...};
It might as well have been called _someVar.
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