ive been able to get the if variable to work as well only thing is it
doesn't respond to if the value is exactly the same and i want it to
use only the first number from the calculation only.

 Script so far.

(function($){

$.fn.testwidth = function(){

var element = this;

$(element).load(function(){

changeCss();

$(window).bind("resize", function(){
    changeCss();
});

function changeCss(){

        var box = $(".box");
    var windowWidth = box.innerWidth();
        var calculation = (windowWidth - 300) / 152;

/*i want to use first digit of calculation only*/
  if (calculation=='2'){
   var answer=200;
    }
  else if(calculation=='3'){
   var answer=300;
    }
  else if (calculation=='4'){
   var answer=400;
    }
  else if (calculation=='5'){
   var answer=500;
    }
   else {
   var answer=1000;
    }

        $(element).css({
        "width" : answer
    });

};
});

};

})(jQuery);

If someone can show me how to make it use only the first digit from
calculation in the if that would be great.

Thanks,
dP

Reply via email to