Bjo*_*ngi 6 twitter-bootstrap drop-down-menu
我没有让这个工作.下拉列表一直在关闭.
我希望能够从下拉菜单中发送消息.
我包括了两个bootstrap.js,bootstrap.css并bootstrap-responsive.css在标题中.
如何才能让这个下拉菜单关闭?
<head>
<script type='text/javascript'>//<![CDATA[
$(window).load(function () {
$('.dropdown-menu textarea a').click(function (e) {
e.stopPropagation();
});
});
function ShowDr(div) {
$("#medr" + div).css("display", "block");
$("#xdr" + div).focus();
}
//]]>
</script>
</head>
<body>
<ul class="nav">
<li class="dropdown" data-dropdown="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown"> Message
<b class="caret"></b></a>
<ul class="dropdown-menu dropdown-menu-large">
This is a message from the user John to Ann. If Ann wants to send an answer she will click the link. Then
the textarea will become visible.
<a href="javascript:void(0)" onclick="javascript:ShowDr('18')"><img src='/img/reply.gif'> Answer</a><br/>
<div id="medr18" style="display:none" class="medr">
<li>
<div style="padding:20px;">
<textarea name="xdr18" id="xdr18" class="textareasmall"></textarea> <br /><input type=button value="Send" class="btn btn-success btn-medium" onclick="GoM('2','Message sent')" />
</div>
</li>
</div>
</ul>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
And*_*ich 11
您需要正确选择textarea才能使stopPropagation()方法正常工作.试试这个:
JS
$('.dropdown-menu textarea').click(function(e) {
e.stopPropagation();
});
Run Code Online (Sandbox Code Playgroud)
此外,您的textarea不能是ul元素的子元素,因此请将其包含在li列表项中.
您缺少 <form> 标签:
<ul class="nav">
<li class="dropdown" data-dropdown="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown"> Message
<b class="caret"></b></a>
<ul class="dropdown-menu dropdown-menu-large">
<form>
<textarea name="xd" id="xd" class="textareasmall"></textarea><br /><input type=button value="Send" class="btn btn-success btn-medium" onclick="GoM('2','Message sent')" />
</form>
</ul>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9091 次 |
| 最近记录: |