0
почему "имя" не подлежит замене здесь.replace() не работает должным образом
var foo = '<div> <label class="required">_1_label__</label><div id="project_frontendbundle_car_1___name__"><div> <label for="project_frontendbundle_car_carImages___name___position" class="required">Position</label><input type="number" id="project_frontendbundle_car_carImages___name___position" name="project_frontendbundle_car[carImages][__name__][position]" required="required" /></div><div> <label for="project_frontendbundle_car_carImages___name___fileName">File name</label><input type="text" id="project_frontendbundle_car_carImages___name___fileName" name="project_frontendbundle_car[carImages][__name__][fileName]" maxlength="2000" /></div></div></div>';
var bar = foo.replace('_name_', '1');
$('body').text(bar);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Он заменен. Но только первое вхождение. – Oriol
http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript, возможно, эта помощь. – ventaquil