见:是否有可能使用 jQuery Mobile 即时创建元素? 或 http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.html$('#leftnav').listview('refresh') 是您要寻找的东西,而不是创建的东西.参见:http://api.jquerymobile.com/listview/#method-refreshwhen appending items to my list, the complete style of jquery mobile is gone... dont know how to fix this?This is currently working: when not appending the list-items, all styles are fine.<div class="ui-grid-a"> <div class="ui-block-a" id="blockaid"> <ul id="leftnav" data-role="listview" data-theme="g" data-filter="true" > <li><a href="index.html"> <img src="images/bb.jpg" /> <h3>Firstname Lastname</h3> <p>123456789</p> </a></li> </ul> </div> <div class="ui-block-b"> ...But if I start using to read the data from else where, all styles are gone: $(document).ready(function() { $.ajax({ url: 'test.xml', dataType: "xml", success : parse, error : function (xhr, ajaxOptions, thrownError){ alert(xhr.status); alert(thrownError); } }); function parse(document){ $(document).find("Details").each(function(){ $("#leftnav").append( '<li>' + '<a href="#">' + '<img src="images/album-xx.jpg" />' + '<h3>' + $(this).find('Name').text() + '</h3>' + '<p>' + $(this).find('Number').text() + '</p>' + '</a>' + '</li>' ); }); } });Whats wrong?Thanks! 解决方案 Well, to trigger the automatic style on new elements, using .trigger("create") should do the job.see : Is it possible to create element on the fly with jQuery Mobile?or http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.htmlEDIT: $('#leftnav').listview('refresh') is the thing your looking for rather than create.see: http://api.jquerymobile.com/listview/#method-refresh 这篇关于JQuery 移动 ->.append() 删除 CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-12 03:08