Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Jquery打开基于URL中标签的模式_Javascript_Jquery - Fatal编程技术网

Javascript 如何使用Jquery打开基于URL中标签的模式

Javascript 如何使用Jquery打开基于URL中标签的模式,javascript,jquery,Javascript,Jquery,我试图打开一个模块时,url有一个特定的标签。但当我在我的url中添加一个标签时,似乎什么也没发生。任何帮助都将不胜感激。代码如下: <div id="overlay"> <div class="howlModal"> <iframe width="300" height="315" src="https://www.youtube.com/embed/UP34u6rdscs" frameborder="0" allowfullscre

我试图打开一个模块时,url有一个特定的标签。但当我在我的url中添加一个标签时,似乎什么也没发生。任何帮助都将不胜感激。代码如下:

<div id="overlay">
     <div class="howlModal">
          <iframe width="300" height="315" src="https://www.youtube.com/embed/UP34u6rdscs" frameborder="0" allowfullscreen></iframe>
     </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $('.howlModal').hide();

    var hash = window.location.hash.substr(1);
    switch(hash) {
    case '#howl':
        $('howlModal').show();
        break;
    }
});
</script>

$(文档).ready(函数(){
$('.howlModal').hide();
var hash=window.location.hash.substr(1);
开关(散列){
案例“嚎叫”:
$('howlModal').show();
打破
}
});

请试试这个

$(document).ready(function(){
    $('.howlModal').hide();

    var hash = window.location.hash.substr(1);
    switch(hash) {
    case '#howl':
        $('.howlModal').show();
        break;
    }
});

$('.howlModal').show()不是$('howlModal')。show()请试试这个

$(document).ready(function(){
    $('.howlModal').hide();

    var hash = window.location.hash.substr(1);
    switch(hash) {
    case '#howl':
        $('.howlModal').show();
        break;
    }
});

$('.howlModal').show()不是$('howlModal')。show()

谢谢,但这似乎对我不起作用。我正试图让它做这样的事情:谢谢,但这似乎对我不起作用。我试图让它做这样的事情:如果你把散列放在url中并点击回车,页面将不会重新加载,你是否尝试将你的url与散列一起粘贴到新的浏览器选项卡中,或者用ctrl-r(在chrome上)重新加载页面?如果你把散列放在url中并点击回车,页面将不会重新加载,您是否尝试在新浏览器选项卡中使用哈希值粘贴url,或使用ctrl-r(在chrome上)重新加载页面?