This fiddle應該讓你開始。如果你擔心IE7,請注意ie7有一些問題。您可以通過一些條件樣式來解決問題。
打破它
HTML
<div class="multiButton">
<input class="main" type="button" Value="Set Up"/><input type="button" class="Selector" value="^"/>
<ul class="options">
<li><a href="linka.html">Set Up</a></li>
<li><a href="linkb.html">Update</a></li>
</ul>
</div>
<div>Some more content</div>
CSS
/*This is the "Slider"*/
.multiButton ul
{
display:none;
border: solid 1px black;
width:75px;
position: absolute;
background-color:#FFF;
}
/*Main Part of the button*/
.multiButton .main
{
border: solid 1px black;
width:60px;
}
/*Slider "trigger"*/
.multiButton .Selector
{
border: solid 1px black;
border-left:none;
width:15px;
}
/*The Whole "Button"*/
.multiButton { position: relative;}
的Javascript
/* Trigger the dropdown */
$(".multiButton .Selector").click(function(){
$(".multiButton ul").slideToggle();
});
/* Slide up the drop down if the mouse leaves the button */
$(".multiButton").mouseleave(function() {
$(this).children("ul").slideUp();
});
/* Change the button text and slide the dropdown up on link click */
$(".multiButton a").click(function(){
$(this).closest(".multiButton").children(".main").val($(this).text());
$(this).closest(".options").hide();
return false; /* Remove this line if you want to use the links in the drop down */
});
注意:這只是爲了讓你開始。您可能需要連接更多的事件處理程序,以便根據您的需要單擊鏈接上的按鈕。
謝謝!這非常有幫助。 – Snowburnt 2012-08-07 16:47:49