如果退出jquery移动基础结构是不好的做法,那我就很伤心。在我的示例中,我得到了完全相同的代码。但是在另一个标签中,我在-tag之前添加了一个div。这给了我另一种眼神,因为CSS是不正确的。
不好吗它打乱了我的帅气名单。并且有什么好的解决方案吗?
原因是因为我希望对列表中的信息进行某种控制,以使用som jQuery显示和隐藏div。我将解决此问题,为li -tag提供一个类,然后隐藏并显示它。但是我还是有点困惑
如果我有此代码(摘自jquery演示页):
<li>
<a href="#">
<h2>
Stephen Weber</h2>
<p>
<strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p>
<p>
Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the
jQuery team.</p>
</a>
<p class="ui-li-aside">
<strong>6:24</strong>PM</p>
</li>
它将生成以下html:
<li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" data-corners="false"
data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="false"
data-iconpos="right" data-theme="c">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<p class="ui-li-aside ui-li-desc">
<strong>6:24</strong> PM
</p>
<a class="ui-link-inherit" href="#">
<h2 class="ui-li-heading">
Stephen Weber</h2>
<p class="ui-li-desc">
<strong>You've been invited to a meeting at Filament Group in Boston, MA</strong>
</p>
<p class="ui-li-desc">
Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the
jQuery team.</p>
</a>
</div>
</div>
</li>
但是,如果我在代码中添加div像这样:
<li>
**<div>**
<a href="#">
<h2>
Stephen Weber</h2>
<p>
<strong>You've been invited to a meeting at Filament Group in Boston, MA</strong></p>
<p>
Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the
jQuery team.</p>
</a>
<p class="ui-li-aside">
<strong>6:24</strong>PM</p>
</div>
</li>
它将生成以下html:
<li class="ui-li ui-li-static ui-btn-up-c">
<div>
<p class="ui-li-aside ui-li-desc">
<strong>6:24</strong> PM
</p>
<a class="ui-link" href="#">
<h2 class="ui-li-heading">
Stephen Weber</h2>
<p class="ui-li-desc">
<strong>You've been invited to a meeting at Filament Group in Boston, MA</strong>
</p>
<p class="ui-li-desc">
Hey Stephen, if you're available at 10am tomorrow, we've got a meeting with the
jQuery team.</p>
</a>
</div>
</li>
最佳答案
jQuery Mobile已经有一个解决listview元素的方法。因此,无需使用父div包装li元素。
这是为您提供的解决方案:http://jsfiddle.net/Gajotres/TvwnQ/
$(document).on('pagebeforeshow', '#index', function(){
// Hide first listview element
$('#mylist li').eq(0).addClass('ui-screen-hidden');
});
基本上,您只需要在listview li元素上切换ui-screen-hidden类。
关于jquery - jQuery的HTML移动结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15902083/