我有一个有两行的表,每一行都有一个按钮。我希望第二个按钮弹出一个模态,但当我运行我的代码时,我应该弹出的窗口模式点击"查看购物车"按钮不会弹出。相反,当我将页面更改为我拥有"查看购物车"的页面时,它已经存在。按钮。任何人都可以帮我解决这个问题吗?
<table>
<tr>
<div class="btn_form" style="length :150px;">
<form method="post" action="single.php">
<input type="image" name="cart" value=<?php echo $array[0]['ProductID']?>image src="img/cart.png height="100px" width="100px" onClick="document.submitForm.hidbrand.value=this.value; document.submitForm.submit();" />
</form>
</div>
</tr>
<tr>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View Cart</button>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</tr>
</table>
答案 0 :(得分:0)
将你的模态移到桌子外面,你忘了包含定义模态脚手架的前两个DIV。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<table>
<tr>
<div class="btn_form" style="length :150px;">
<form method="post" action="single.php">
<input type="image" name="cart" value="<?php echo $array[0]['ProductID']; ?>" src="img/cart.png" height="100px" width="100px" onClick="document.submitForm.hidbrand.value=this.value; document.submitForm.submit();" />
</form>
</div>
</tr>
<tr>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">View Cart</button>
</tr>
</table>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
&#13;
参考文献: