我想创建一个类似Photoshop的按钮,即一个按钮:
我到目前为止所处的位置:https://jsfiddle.net/25mc3mtz/2/
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div class="btn-group">
<a class="btn btn-large" id="myDropdown" href="#" onmousedown="func()" onmouseup="revert()">
<i class="icon-file"> </i>
</a>
<ul class="dropdown-menu">
<li><a href="#">Menu Item 1</a>
</li>
<li><a href="#">Menu Item 2</a>
</li>
</ul>
</div>
<script>
var timer;
var isTrue = false;
function func() {
$("#myDropdown").attr('data-toggle', '');
$("#myDropdown").removeClass('dropdown-toggle');
isTrue = true;
timer = setTimeout(function() {
showDropDown();
}, 1000);
}
function showDropDown() {
if (timer)
clearTimeout(timer);
if (isTrue) {
$("#myDropdown").attr('data-toggle', 'dropdown');
$("#myDropdown").addClass('dropdown-toggle');
$("a .dropdown-toggle").trigger('click');
}
}
function revert() {
isTrue = false;
}
</script>
&#13;
我想知道:
提前致谢!