【发布时间】:2013-04-09 12:36:33
【问题描述】:
如果从 jquery 移动基础结构中跳出是不好的做法,我会感到很痛苦。在我的示例中,我得到了完全相同的代码。但在另一个中,我在 -tag before 添加了一个 div。这让我再看一眼,因为 css 不正确。 不好吗?它打破了我好看的清单。有什么好的解决办法吗?
原因是因为我想要对列表中的信息进行一些控制,以使用 som jQuery 显示和隐藏 div。我会很容易地解决这个问题,给 li 标签一个类并隐藏和显示它。但是我还是有点困惑
如果我有这段代码(取自 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 希望允许您更改其基本的小部件结构,但您可以在它们之上工作。
-
正如@Gajotres 所说,您可以通过更改 JQM CSS 类来操作 JQM。
标签: jquery css jquery-mobile jquery-mobile-listview