我想添加一個像這樣的元素fiddle但我有一個問題,當字符串具有UTF-8字符時,因爲"é" is > at all basics letters
而比較我的字符串。如何比較包含撥號字符的兩個UTF-8字符串
<ol class="ingredientList">
<li class="ingredient">Apples</li>
<li class="ingredient">Carrots</li>
<li class="ingredient">Clams</li>
<li class="ingredient">Oysters</li>
<li class="ingredient">Wheat</li>
</ol>
<ol class="ingredientList">
<li class="ingredient">Barley</li>
<li class="ingredient">éggs</li>
<li class="ingredient">Millet</li>
<li class="ingredient">Oranges</li>
<li class="ingredient">Olives</li>
</ol>
$(".ingredient").click(function() {
var element = $(this);
var added = false;
var targetList = $(this).parent().siblings(".ingredientList")[0];
$(this).fadeOut("fast", function() {
$(".ingredient", targetList).each(function() {
if ($(this).text() > $(element).text()) {
$(element).insertBefore($(this)).fadeIn("fast");
added = true;
return false;
}
});
if (!added) $(element).appendTo($(targetList)).fadeIn("fast");
});
});
你有什麼解決方案來解決這個問題?
看一看[這](http://stackoverflow.com/questions/286921/efficiently-replace-all-accented-characters-in-a-string)。 – Huelfe