這裏我試圖通過使用按鈕點擊事件顯示一個模態彈出窗口。顯示一個模態彈出窗口
這是模式彈出師
<div id="myModalPopup" class="modal fade" role="dialog" data-keyboard="false">//Modal popup
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="background-color: orangered; border-top-left-radius: 4px; border-top-right-radius: 4px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Company Details</h4>
</div>
<div class="modal-body">
<asp:Panel ID="Panel2" runat="server" class="tab-pane">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-4">
<asp:Label runat="server" ID="lblNmeComp" Text="Name of Company" AssociatedControlID="txtNmeComp" CssClass="control-label" />
<asp:TextBox runat="server" ID="txtNmeComp" CssClass="form-control" />
<br />
</div>
<div class="col-sm-4">
<asp:Label runat="server" ID="lblAdrComp" Text="Address of Company" AssociatedControlID="txtAdrComp" CssClass="control-label" />
<asp:TextBox runat="server" ID="txtAdrComp" CssClass="form-control" />
<br />
</div>
這是我的按鈕代碼
<button id="AddMore_Button" class="btn btn-primary" data-target="myModalPopup">Add More</button> //button for Add more
這是我的Jquery。
<script type="text/javascript">
$(document).ready(function() {
// Attach Button click event listener
$("#AddMore_Button").click(function() {
$('#myModal').modal('show');
// alert('a');
});
});
</script>
在這裏,當我點擊按鈕,它不顯示任何東西,然後刷新並進入第一屏幕。如果我把alert()它觸發,並在按下確定後發生同樣的事情。
向我們展示了HTML也 – Akki619
能否請你把的jsfiddle鏈接你會怎麼做了嗎? –
http://jsfiddle.net/AUyTH/108/ –