将图像添加到可折叠内容标题

时间:2011-05-26 20:14:30

标签: jquery jquery-mobile

我正在关注可折叠内容文档 - http://jquerymobile.com/demos/1.0a4.1/docs/content/content-collapsible.html

是否有一种方法可以在标题字段中向右添加图像(在标题字段下方的代码中,由'Test'引用)。

<div data-role="collapsible" data-collapsed="true">
        <h3>Test</h3><add image here>
    </div>

我似乎无法在文档中找到任何内容。

感谢您的帮助

2 个答案:

答案 0 :(得分:6)

HTML

<div data-role="page" id="home"> 
    <div data-role="content">
        <div data-role="collapsible">
            <h3>I'm a header</h3>
            <p>I'm the collapsible content.</p>
        </div>
        <div data-role="collapsible" data-collapsed="true">
            <h3>With Image <img src="http://jquerymobile.com/demos/1.0a4.1/docs/lists/images/us.png" alt="US Flag" /></h3><p>I'm another collapsible content.</p>
        </div>
    </div>
</div>

答案 1 :(得分:0)

在主div中使用左右浮动的两个div怎么样?

<div data-role="collapsible" data-collapsed="true">
    <div style="float: left;"><h3>Test</h3><add image here></div>
    <div style="float: right;"><img src="parth/to/image.ext" /></div>
</div>