您能告诉我如何在jQuery mobile中创建自定义下拉菜单吗?

我需要创建一个看起来像dropdown的按钮,并且onclick将显示带有列出的选项的弹出div。当用户选择一个选项时,弹出窗口将关闭,并将按钮的值设置为所选项目。

我需要简单的方法来做事。这是我知道的唯一方法。在所有平台上看起来都一样吗?

最佳答案

使用此代码:

HTML:

CSS:

<a href="index.html" data-role="button" id="Click">DropDown</a>
<a href="#"  data-role="button" id="Drop">Click Here</a>
<div id="container">
<div id="fixed">
    <a href="#" name="test1">test1</a>
    <a href="#" name="test2">test2</a>
    <a href="#" name="test3">test3</a>
    <a href="#" name="test4">test4</a>
</div>
</div>

jQuery的:
#fixed{
    display:table;
    position:fixed;
    width:46%;
    height:46%;
    top:25%;
    left:25%;
    background:#fefefe;
    border:5px solid grey;
    border-radius:10px;
    padding:2%;
    z-index:2;
}
#container{
    position:fixed;
    width:100%;
    height:100%;
    background:#000;
    opacity:0.5;
    top:0;
    display:none;
}

#fixed a{
    display:table-row;
    text-align:center;
}

10-06 07:56
查看更多