[英]How to make a dropdown menu with span tag and glyphicon instead of button on bootstrap?
Here's the code that you're looking for, that with jquery: 这是您要查找的,带有jquery的代码:
$('#willtoggle').on('click', function (event) {
$("#toggled").toggle();
});
the #willtoggle is a span with the class of caret defined on bootstrap, so on click, it'll toggle the dropdown-menu(that have the id="toggled"). #willtoggle是一个在引导程序上定义了插入符号类的跨度,因此在单击时,它将切换下拉菜单(具有id =“ toggled”)。
And this code for hiding it when clicking outside: 并在外部单击时隐藏该代码:
$(document).on('click', function(event) {
if ($(event.target).closest('.dropdown').length === 0) {
$("#toggled").hide();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.