[英]Convert alert message into pop-up
I am able to create a alert message when user click a particular set of product but How do I display pop-up instead of alert message Code: 当用户单击一组特定的产品时,我可以创建警报消息,但是如何显示弹出窗口而不是警报消息代码:
<script>
$(document).ready(function(){
$('.pre-sale-product').on('click', function(){
$('.productcart').addClass('pre-sale-item-included');
});
$('.productcart').on('click', function(){
if($(this).hasClass('pre-sale-item-included')){
alert('will ship on <?php echo $new_date?>. Do you agree?');
}
});
})
</script>
<!-- Modal -->
<div class="modal fade" id="myModal_product" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<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>
I want this pop-up instead of alert with option saying tick yes as a check box and it moves further 我希望此弹出窗口而不是带有选项“勾选是”的警报,它会进一步移动
You just need to use the $('#myModal_product').modal('show');
您只需要使用
$('#myModal_product').modal('show');
Try this: 尝试这个:
$(document).ready(function() { $('.pre-sale-product').on('click', function() { $('.productcart').addClass('pre-sale-item-included'); }); $('.productcart').on('click', function() { if ($(this).hasClass('pre-sale-item-included')) { $('#myModal_product').modal('show'); } }); })
.pre-sale-item-included { border-color: red; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <!-- Modal --> <div class="modal fade" id="myModal_product" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <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>Will ship on <?php echo $new_date?>. Do you agree?</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-success btn-default" data-dismiss="modal">Yes</button> <button type="button" class="btn btn-danger btn-default" data-dismiss="modal">No</button> </div> </div> </div> </div> <input type="button" class="pre-sale-product" value="pre-sale-product" /> <input type="button" class="productcart" value="productcart" />
Add $('#myModal_product').modal('show');
添加
$('#myModal_product').modal('show');
to your script instead of alert. 而不是警报。 And add your messages inside your modal
并将您的消息添加到模态中
<script>
$(document).ready(function(){
$('.pre-sale-product').on('click', function(){
$('.productcart').addClass('pre-sale-item-included');
});
$('.productcart').on('click', function(){
if($(this).hasClass('pre-sale-item-included')){
$('#myModal_product').modal('show');
}
});
})
</script>
If you want to open a modal... try this 如果要打开模态...请尝试此
$('#myModal_product').modal('show'); $('#myModal_product')。modal('show');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.