I need to change the text in all
<option ...> ... </option>
XX
GHO.502/TT3-XX04-F.P1
XX
XX
<select>
_savedSelect = $('#mySelect');
XX
<option>
<select>
$("#mySelect").selectpicker('refresh');
XX
$("#mySelect > option").each(function () {
$newtext = HOW TO GET CORRESPONDING TEXT FROM _savedSelect??;
this.text = $newtext.replace( 'XX', $('#someInput').val() );
});
$("#mySelect").selectpicker('refresh');
$("#mySelect> option").each(function () {
$textarr = $(this).text().split('XX');
$newtext = $textarr[0] + $('#someInput').val() + $textarr[1];
$(this).text($newtext);
});
XX
#mySelect
Try the following, clone the select after page load, loop it and based on the value of cloned element change the on page elements text to the desired text
$cloned = $("#mySelect").clone();
$('input').on('change',function(){
$cloned.find('option').each(function () {
$textarr= $(this).text().split('XX');
console.log($textarr);
$newtext = $textarr[0]+$('input').val()+$textarr[1];
$("#mySelect > option[value='"+$(this).val()+"']").text($newtext);
});
});