根据返回数据中的第一个字母插入数据
continue
I am using an xml file to pull in data to jqm. I am appending the first and last name to a listview. (I am working with Datazombies example for the a-z index contact list from the iscroll git hub). How would I specify where to append ie, if the lastname is Adams (or anything that begins with letter A) Adams is appended under the listdivider with ID of A.
Sorry about that thought I included code
$.ajax({
type: "GET",
url: "Contacts.xml",
dataType: "xml",
success: ContactsXml,
});
function ContactXml (lxml) {
$(lxml).find("COMBINED").each(function() {
$("#A").append('<li id="item"><a href="#ldetails">'
+ $(this).find("FIRSTNAME").text() + ' '
+ $(this).find("LASTNAME").text() + '</a></li>');
})}
</script>
<div id="header" data-role="header" data-backbtn="true">
<a href="#page" data-role="button" data-icon="arrow-l">BACK</a><h1>CONEX</h1></div>
<div>
<!-- //left scroll-->
<div id="wrapper" style="overflow-x: hidden; overflow-y: hidden; ">
<div id="scroller" style="-webkit-transition-property: -webkit-transform; -webkit-transition-
<ul id="thelist">
<li class="heading" id="A"><span>A</span></li>
<li id="item"></li>
<li class="heading" id="B"><span>B</span></li>
<li class="heading" id="C">C</li>
<li class="heading" id="D">D</li>
<li class="heading" id="E">E</li>
<li class="heading" id="F">F</li>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你的问题完全没有任何示例标记或脚本,所以这里有一个通用方法:
JS:
HTML:
Well your question is completely void of any sample markup or script, so here's a general approach:
JS:
HTML: