Opened 14 years ago
Closed 13 years ago
#5013 closed enhancement (fixed)
Enhancement: val(callback)
Reported by: | pmcelhaney | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | Cc: | [email protected]… | |
Blocked by: | Blocking: |
Description
I was inspired by this question on Stack Overflow: http://stackoverflow.com/questions/1224133/1224191.
Modifying a val() on a form element feels a bit kludgy. If val took a function as an argument (which gets the original value and returns the new one), we could do things like this:
From the SO question
$('#abc').val(function(v) { return v + "test"; });
More realistic example
var formatPhoneNumber = function (input) { ... };
...
$('.phone').val(formatPhoneNumber); }
Note: See
TracTickets for help on using
tickets.
This is in the nightlies already and should be in 1.3.3.