我有下面这段代码,指的是通常只有像“#programs”一样的页面链接的href。但是,我现在需要一些链接来引用其他页面,如“/index.html#programs”。所以我的问题是,如何编辑下面的代码中的“href”,以便只是数字符号和后面的所有符号?谢谢。删除字符串href
var lastId, topMenu = $("#main-menu"),
topMenuHeight = topMenu.outerHeight() + 500;
menuItems = topMenu.find('a');
scrollItems = menuItems.map(function() {
content = $(this).attr("href");
if(content){
var checkURL = content.match(/^#([^\/]+)$/i);
if(checkURL){
var item = $($(this).attr("href"));
if (item.length) return item
}
}
});
什么是这样做的目的是什么? – charlietfl