REM Calculator!

/*global jQuery */
(function( $ ) {
var result = $(‘#result’);
var base = $(‘#base’);
var list = $(‘#list’);
$(‘#calc’).click(function() {
var baseVal = base.val();
var px = list.val().split(‘,’);
var html = [];
$.each(px, function(i, v) {
var px = parseInt(v);
var rem = parseFloat((px / parseInt(baseVal, 10)).toPrecision(4));
var isBase = (rem === 1) ? ‘ <i>(base)</i>’ : ”;
html.push(‘<li>’ + v + ‘px = ‘ + rem + ‘rem’ + isBase + ‘</li>’);
});
result.html(html.join(”));
}).click();
}(jQuery));

 

REM Calculator!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: