作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 bootstrap(前端)和 codeigniter 开发购物车。当添加到购物车项目时,模式弹出窗口显示添加项目的详细信息。但我的问题是页面滚动在模式弹出窗口中移动到顶部。
<a href="#" id="edit_product" data-id="<?php echo $lat['product_id'];?>" name="id" data-text="Add To Cart" class="my-cart-b item_add add_to_cart">Add To Cart</a>
Ajax
$(".product_add").click(function(event) {
var currentId = globalId;
$.ajax({
type: 'POST',
url: '<?php echo site_url("ajax_controller1/product_add/'+currentId+'")?>',
data: { id:'1' },
success:function(response){
$("#cart_container1").html(response);
$("#myModal3").modal('show');
}
});/* Aajx */
});
模态
<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" style="overflow: visible;">
<div class="modal-dialog" role="document" style="overflow: visible;">
<div class="modal-content modal-info" style="overflow: visible;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body" id="cart_container1">
</div>
</div>
</div>
</div>
为了解决这个问题,我做了以下工作
$('a.add_to_cart').click(function(e) {
e.preventDefault();
});
body.modal-open {
overflow: visible;
}
这是我的演示网站链接
最佳答案
我觉得罪魁祸首是href="#"
你可以做两件事,
href="#"
更改 <a>
`
<button type="button" id="edit_product" data-id="<?php echo $lat['product_id'];?>" name="id" data-text="Add To Cart" class="my-cart-b item_add add_to_cart">Add To Cart</button>
这应该对你有帮助。
注意我添加了type="button"
如果您采用第二种方法。
关于javascript - 页面在模态弹出窗口上滚动到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44472611/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!