javascript - return a value via function math result that is stored in a variable -
i trying result of browsers window width , trying put result of math , condition in variable , code
var mywidth = 1900; var myheight = 900; var height = $(window).height(); var width = $(window).width(); var autow = function () { if ( (mywidth / width).tofixed(2) > 0.95 ) return 1; if ( (mywidth / width).tofixed(2) < 1.05 ) return 1; else return (mywidth / width).tofixed(2); }; alert(autow);
the problem don't know right syntax or structure of function assigned variable
what right way code ?
alert(autow());
autow()
returns value of function assigned variable.
fiddle : http://jsfiddle.net/v2esf/
Comments
Post a Comment