我正在尝试创建包含登录表单的html菜单,所以当我展开菜单时,会出现一个登录表单,问题是当我单击表单以写入用户名或密码时,菜单会自动折叠并且登录表单消失在我在里面写任何东西之前
这是我的菜单和其中的表格的图像。
<body>
<div class="wrapper-demo">
<div id="dd" class="wrapper-dropdown-3" tabindex="1">
<span>LogIn</span>
<ul class="dropdown">
<li>
Username<input type="text" id="UN"><br/>
password<input type="text" id="pass"><br/>
<input type="submit" id="login" value="login">
</li>
</ul>
</div></div>
</div>
<!-- jQuery if needed -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
function WTF() {
window.location.href = "";
}
function DropDown(el) {
this.dd = el;
this.placeholder = this.dd.children('span');
this.opts = this.dd.find('ul.dropdown > li');
this.val = '';
this.index = -1;
this.initEvents();
}
DropDown.prototype = {
initEvents: function () {
var obj = this;
obj.dd.on('click', function (event) {
$(this).toggleClass('active');
return false;
});
}
}
$(function () {
var dd = new DropDown($('#dd'));
$(document).click(function () {
// all dropdowns
$('.wrapper-dropdown-3').removeClass('active');
});
});
</script>
</body>