私は次のhtmlを持っています
<div class="ui-widget" style="margin-top: 1em; font-family: Arial">
Selected:
<div id="locationLog" style="height: 100px; width: 200px; overflow: auto;" class="ui-widget-content"></div>
</div>
<input type="hidden" name="HiddenLocations" id="HiddenLocation" />
次に、ページが読み込まれるたびに実行されて、locationLog
divにテキストを追加するコードがあります。
@if (Model.SearchCriteria != null && Model.SearchCriteria.Locations != null)
{
foreach (string t in @Model.SearchCriteria.Locations)
{
<script type="text/javascript">
$("<div/>").text('@t').appendTo("#locationLog");
$("<br/>").text("").appendTo("#locationLog");
$("#locationLog").scrollTop(0);
selectedLocations = $('#locationLog' + ' div').map(function () {
return $(this).text();
}).get();
$('input[name=HiddenLocations]').val(selectedLocations);
</script>
}
}
これで、このコードは「ロンドン」などのテキストがある場合はうまく機能しますが、「レイキャビク」がある場合は、「」と記述されReykjavík
ます。どうすれば正しいテキストを書き出すことができますか?