如果URL中存在#something,则关闭div

时间:2009-12-10 21:48:50

标签: jquery

我如何使用jquery切换div关闭,如果URL http://www.mydomain.co.uk/index.php#something中存在#something,则隐藏下面的框(关闭它)

<div id="feature">content</div>

2 个答案:

答案 0 :(得分:1)

$(function() {
    if(window.location.hash.indexOf('something') !== -1) {
        $('div#feature').hide();
    }
});

答案 1 :(得分:0)

选中window.location.hash

if (window.location.hash == "something") $("#featured").hide();