我不明白为什么我用子方法来声明一个变量得到错误信息.
我想在比较中使用URL的第一部分.
网站:http://www.elizabet.nl/wordpress
这是出错的部分:
var currentLocation = document.location,
muzLoc = currentLocation.substring(0,45),
prodLoc = currentLocation.substring(0,48),
techLoc = currentLocation.substring(0,47);
Run Code Online (Sandbox Code Playgroud)
错误:"currentLocation.substring不是函数"
但这部分代码很好:
var URL = $(this).attr("href").substring(2) + ' #main';
Run Code Online (Sandbox Code Playgroud)
所有代码:
jQuery(function($){
var siteURL = "http://" + top.location.host.toString() + "/wordpress", // Declareren van URL van de website.
URL = '', // Declareren van een URL, welke dan ook.
currentLocation = '',
muzLoc = '',
prodLoc = '',
techLoc = '',
allLinks = $('a[href^=' + siteURL + ']' ), // Declareren van …Run Code Online (Sandbox Code Playgroud) 我想在点击链接后滑动一个div,然后再滑动另一个div,然后转到下一页.
问题:在动画完成之前加载新页面.
问题:我该怎么办?
我应该使用preventDefault然后以某种方式恢复它吗?
这是URL:http://www.jolandaschouten.nl/wordpress
这是代码,现在只对第一个菜单项实现:
jQuery(document).ready(function($){
var allDivs = $("#introductie").add("#agenda").add("#werk").add("#onderwijs-organisatie").add("#publicaties").add("#links").add("#contact");
console.log(allDivs);
$("li.page-item-11 a").click(slideUp);
function slideUp(){
allDivs.slideUp(500, slideDown);
}
function slideDown(){
$("#introductie").slideDown(500);
}
});
Run Code Online (Sandbox Code Playgroud)
ps:我不想使用AJAX,因为SEO和浏览器导航问题.点击应该真正导致进入下一页.