答案 0 :(得分:0)
window.location.href.split('#')[0]
你可以试试!
答案 1 :(得分:0)
我认为这正是您正在寻找的...(即当您点击其href中包含哈希的超链接时,您想要去除哈希并导航到剩余的URL?)
<!DOCTYPE html>
<html>
<body>
<a id="someLink" href="/some_page#some_hash">Click Me</a>
<script src="http://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
$('#someLink').click(function (e) {
// Prevent normal navigation to the href (the full URL with hash)
e.preventDefault();
// Navigate to "/some_page" (everything to left of the first "#")
document.location = this.href.split('#')[0];
});
</script>
</body>
</html>