我在页面上有 4 个具有唯一 ID 的 div。外部链接示例:
www.website.com/page.html#one
.
我需要将显示(设置为无)更改为阻止。我有点不知所措(我的 JavaScript 不是很强大)。有任何想法吗?下面是我用来分割 url 的代码,而 div id 的字面意思是one
, two
, three
, and four
。
$(document).ready(function()
{
var hashVal = window.location.hash.split("#")[1];
$("#" + hashVal).style.display = 'block';
});