Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery underscore notation

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
like image 381
eidsza Avatar asked Jun 11 '26 13:06

eidsza


1 Answers

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.

like image 55
bldoron Avatar answered Jun 14 '26 03:06

bldoron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!