Skip to content Skip to sidebar Skip to footer

Jquery Return A Function To A Variable

Is there any way to set a variable equal to a function, but instead of the variable being equal to the function it is equal to the functions return value? Searched for a bit on thi

Solution 1:

If I'm understanding you correctly, you're trying to set a variable to the result of a function. This should do what you're hoping for;

var ztype = function(){ //can be set to Full / percentage / Image / left empty for native image size
    var type = $('.carousel').attr('data-zoom');
    if(!type){
        type = $(that).attr('data-zoom');
    }

    return type;
}();

Post a Comment for "Jquery Return A Function To A Variable"