8
Dec
Tweet

Convert a value to pixels with JavaScript

A quick snippet of JavaScript to convert values to pixels from any string. Below is a quick function:

function px(val) {
    return parseInt(val)+"px";
  }
}

To use it, just wrap your string with the function
and it should convert it to pixels for you:

var oldValue = '65';
var newValue = px(oldValue);

Leave a comment

Creative Resume Template
Open source icons