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, ''));
  2.  
  3. Usage would be:
  4.  
  5. var totalWidth = parseInt($('.portfoliowrapper').css('width').replace(/[^-\d\.]/g, ''));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.