使用此代码:
JsFiddle 演示。
HTML:
<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>
CSS:
#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;
}
查询:
$( "#Click" ).click(function() {
alert( "Handler for .click() called." );
});
$( "#Drop" ).click(function() {
$("#container").show();
});
$( "#container" ).click(function() {
$("#container" ).hide();
});
$( "#fixed a" ).click(function() {
document.getElementById('Drop').innerHTML=this.name;
});