Javascript 平滑滚动(需要替代解决方案)
我在我的一个模板中使用了这个片段来平滑滚动。来源:Javascript 平滑滚动(需要替代解决方案),javascript,jquery,scroll,twitter-bootstrap-3,smooth-scrolling,Javascript,Jquery,Scroll,Twitter Bootstrap 3,Smooth Scrolling,我在我的一个模板中使用了这个片段来平滑滚动。来源:http://css-tricks.com/snippets/jquery/smooth-scrolling/ <script> $(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\
http://css-tricks.com/snippets/jquery/smooth-scrolling/
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
$(函数(){
$('a[href*=#]:非([href=#])。单击(函数(){
if(location.pathname.replace(/^\/,“”)=此.pathname.replace(/^\/,“”)
&&location.hostname==this.hostname){
var target=$(this.hash);
target=target.length?target:$('[name='+this.hash.slice(1)+']');
if(目标长度){
$('html,body')。设置动画({
scrollTop:target.offset().top
}, 1000);
返回false;
}
}
});
});
但这会导致我的twitter引导模式的javascript代码出现问题(模式就是不显示):
<!-- Modal -->
<script>
$(function() {
$("input#submitt").click(function(){
$.ajax({
type: "POST",
url: "process.php",
data: $('form#contact').serialize(),
success: function(msg){
alert("success: " + msg);
$("#form-content").modal('hide');
},
error: function(){
alert("failure");
}
});
});
});
</script>
$(函数(){
$(“输入#提交”)。单击(函数(){
$.ajax({
类型:“POST”,
url:“process.php”,
数据:$('form#contact')。序列化(),
成功:功能(msg){
警报(“成功:+msg”);
$(“#表单内容”).modal('hide');
},
错误:函数(){
警报(“故障”);
}
});
});
});
如果我删除平滑滚动代码,我的模式工作得很好。我正在寻找一种平滑滚动的替代方法,或者对现有的方法进行任何改进。我可以问你哪种“问题”?…模式只是在单击时不显示。