按字母顺序插入jQuery
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了按字母顺序插入jQuery相关的知识,希望对你有一定的参考价值。
This function will insert items into an orders alphabetically (assuming it's already alphabetical). Initially design to make a smooth single page load/save feature that sotred everything in drop down lists, you guessed it, alphabetically. Can simply be modified to work in any sort of layout (ordered lists was just easier for the example)Example at the link, you can post any questions there too.
function insert(){ var name = $("input[name='insertvalue']").val(); if(name!=''){ var toinsert = true; $("ol.thelist > li").each(function(){ if(name.toUpperCase() < item.toUpperCase()){ if(toinsert){ $(this).before('<li>'+name+'</li>'); toinsert = false; } } }); if(toinsert){ $("ol.thelist").append('<li>'+name+'</li>'); } $("input[name='insertvalue']").val('') } }
以上是关于按字母顺序插入jQuery的主要内容,如果未能解决你的问题,请参考以下文章
csharp 在Swashbuckle Swagger中,此片段允许按字母顺序显示操作。