Posted By

primitiveshaun on 05/30/18


Tagged

forms data-manipulation


Versions (?)

jQuery Plugin to return .val() as a Number


 / Published in: jQuery
 

.val always returns a string, this returns the value as a number

  1. // function
  2. $.fn.nval = function() {
  3. return Number(this.val())
  4. };
  5.  
  6. // call
  7. $('#elementID').nval()

Report this snippet  

You need to login to post a comment.