j查询星级导致页面滚动
jQuery star rating causing page scrolling
在
星级中添加按钮后遇到问题。每次我点击星星时,我的页面都会变得跳跃并滚动到顶部。如何防止此行为?
我的代码:
$(document).ready(function(){
var rate=null;
$(".one-star, .two-stars, .three-stars, .four-stars, .five-stars").click(function() {
rate = $(this).html();
$("#submit_rating").fadeIn("slow");
$("#current_rating").width(rate*30);
});
$('#submit_rating').click(function(){
$.ajax({data: ({ action: 'save_rating', rating: rate, listing_id: <?php echo $id; ?>}), success: function() { window.location.href = '<?php echo $this->escape(URL); ?>'; }});
return false;
});
});
你可以在这里看到我的问题:http://duniakita.org/starrating/
您可能需要
在单击*-stars
时使用e.preventDefault
。
$(".one-star, .two-stars, .three-stars, .four-stars, .five-stars").click(function(e) {
rate = $(this).html();
$("#submit_rating").fadeIn("slow");
$("#current_rating").width(rate*30);
e.preventDefault();
});
相关文章:
- j查询向下滚动到特定段落
- JQuery查询滚动长度/高度
- j查询整页过渡滚动
- j查询滚动顶部麻烦
- j查询星级导致页面滚动
- j查询平滑滚动到新页面链接
- 使用媒体查询在较小的屏幕上仅滚动模态的距离
- j查询平滑滚动到锚点
- 更改窗口.基于媒体查询的滚动位置
- j查询在scrollTop()调用后重置窗口滚动
- j查询基于滚动的淡入和淡出
- j查询页面 每次向下滚动时,在单个页面中按键按下
- 带滚动条更改的 Chrome 媒体查询
- j查询单页滚动不起作用
- j查询窗口滚动事件.每滚动 XX 个像素
- 使用查询的水平图像滚动
- j通过箭头查询可滚动的ul(当到达列表的顶部或底部时删除箭头)
- 通过AngularJS中的按钮点击/滚动来增加Mongoose查询限制
- 由于滚动冲突,JQuery在单击或模糊、停止或终止功能时进行查询
- 实时查询和检测滚动的位置