remove hiddenfield value using jquery
i have set value in hidden field like: D1|12345;D2|34567;
i need to remove value D1\12345; from hidden field usi开发者_JS百科ng jquery.
can anyone suggest me how can i do this?
Try this:
// creat an array from field value, like array('D1|12345','D2|34567')
var field_value_array = $('#field_id').val().split(';');
// write only the second element
$('#field_id').val(field_value_array[1]);
I would suggest http://www.w3schools.com/jsref/jsref_replace.asp
eg:
var newVal = $('#hiddenInput').val().replace('regex or string here','');
$('#hiddenInput').val(newVal);
精彩评论