jquery css values to integers

/ Published in: jQuery
Save to your folder(s)

A quick snippet that removes the 'px' when accessing a value through jquery, and converts it into an integer.

Copy this code and paste it in your HTML
  1. parseInt($('.element-class').css('width').replace(/[^-\d\.]/g, ''));
  3. Usage would be:
  5. var totalWidth = parseInt($('.portfoliowrapper').css('width').replace(/[^-\d\.]/g, ''));

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.