WonderBugger WonderBugger - 4 months ago 26
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?

$('input[name=ids]').val(function(index, value) {
   return value.replace('54,', '');