
anchorTag
anchorTag跨页面锚点脚本
DNN主题 • 舒正兴 发表了文章 • 0 个评论 • 383 次浏览 • 2020-12-29 14:26
$(document).ready(function() {$('pre code').each(function(i, block) { hljs.highlightBlock( block); }); });jQuery(document).ready(function ($) {
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
}) 查看全部
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
}) 查看全部
jQuery(document).ready(function ($) {
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
})
anchorTag跨页面锚点脚本
DNN主题 • 舒正兴 发表了文章 • 0 个评论 • 383 次浏览 • 2020-12-29 14:26
jQuery(document).ready(function ($) {
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
}) 查看全部
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
}) 查看全部
jQuery(document).ready(function ($) {
if(location.hash){
var id = "#"+location.hash.replace(/%20/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(".anchorTag").each(function(){
var thisid = $(this).attr("id");
thisid = thisid.replace(/\s/g,"_").replace(/[&\|\\\*^%$#@!\-]/g,"");
$(this).attr("id",thisid);
console.log($(this).attr("id"))
})
if($(id).length!==0){
$("html, body").animate({
scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
},100)
// setTimeout(function(){
// $("html, body").animate({
// scrollTop: $(id).offset().top + parseInt($(id).data("offset"))
// },100)
// },100)
}
}
})