WonderBugger WonderBugger - 1 year ago 82
jQuery Question

How to replace part of an input value in jquery?

I've been trying to figure out a way to replace part of a string in an input value, but haven't been able to get it working.

the input field looks like this:

<input type="text" value="20,54,26,99" name="ids" />

I've tried:



var replit = $('input[name=ids]').val();

but neither worked?

Answer Source
$('input[name=ids]').val(function(index, value) {
   return value.replace('54,', '');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download