当前位置: 首页 > 知识库问答 >
问题:

jQUery对话框中单击导航栏链接时不工作

江智
2023-03-14
<nav id="nav_bar">
    <ul>
        <li><a class="fancypdf" href="img/resume.pdf">Resume</a></li>
        <li><a>Youtube</a></li>
        <li class="contact" style="cursor:pointer;">Contact</li>
    </ul>
</nav>
<div class='dialog'>
    Hello
</div>
<script>
$(function(){
    $(".contact").click(function(event){
        $(".dialog").dialog({
            width:490,
            height:500,
            draggable:false,
            blur:true,
            show:{
                effect:"blind",
                duration:100
                },
    hide: {
    effect: 'blind',
    duration: 100
    }
        });
});
});
</script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js">    </script>

<script type="text/javascript" src="js/libs/fancybox-2.1.4/jquery.fancybox.pack.js">    </script>
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox-buttons.css">
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox-thumbs.css">
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox.css">

以下是我的所有主要脚本标记:

<script>
$(".fancypdf").click(function(){
$.fancybox({
type: 'html',
autoSize: false,
content: '<embed src="'+this.href+'#nameddest=self&page=1&view=FitH,0&zoom=80,0,0"    type="application/pdf" height="99%" width="100%" />',
beforeClose: function() {
$(".fancybox-inner").unwrap();
}
}); //fancybox
return false;
}); //click
</script>


<!-- Grab Google CDN's jQuery, fall back to local if offline -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">  </script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-  1.7.1.min.js"><\/script>');</script>


<!-- FancyBox -->
<script src="js/fancybox/jquery.fancybox.js"></script>
<script src="js/fancybox/jquery.fancybox-buttons.js"></script>
<script src="js/fancybox/jquery.fancybox-thumbs.js"></script>
<script src="js/fancybox/jquery.easing-1.3.pack.js"></script>
<script src="js/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('.fancybox').fancybox({
beforeShow : function(){
this.title =  this.title + " - " + $(this.element).data("caption");
}
});
}); // ready
</script>



<script type="text/javascript">
$(document).ready(function() {
$(".various").fancybox({
maxWidth    : 800,
maxHeight   : 600,
fitToView   : false,
width   : '70%',
height  : '70%',
autoSize    : false,
closeClick  : false,
openEffect  : 'elastic',
closeEffect : 'none',
beforeShow : function(){
this.title =  $(this.element).data("caption");
}
});
});
</script>

<script>
var jquery = jQuery.noConflict();
jquery(function(){
jquery(".contact").click(function(event){
console.log("clicked");
jquery(".dialog").dialog({
width:490,
height:500,
draggable:false,
blur:true,
show:{
effect:"blind",
duration:100
},
hide: {
effect: 'blind',
duration: 100
}
    });
});
});
</script>

共有1个答案

司马奇希
2023-03-14

看起来您好像忘记包含jQuery UI或者jQuery和jQuery UI的加载顺序不对。

你的代码运行良好。

在jsBin中测试

<link href="http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
 类似资料:
  • 我试图简单地在 元素周围放置一个边框,但是Bootstrap navbar 元素的边框向上到navbar的顶部和底部,这与图片中的情况不同。以下是我努力的样子: 我尝试使用的CSS只是一个简单的边框: 我尝试在链接周围设置边距,但这会使链接与其他链接脱节。我还尝试将SIGN UP按钮包装在div中,但这会使它失去很多引导属性。 有没有什么简单的方法,让我把这个边框周围的注册链接,而不必对抗引导?

  • 问题内容: 我希望此链接具有一个JavaScript对话框,询问用户“ 您确定吗? 是/否 ”。 如果用户单击“是”,则链接应该加载,如果“否”,则什么也不会发生。 我知道如何通过运行返回或的函数以表格形式进行操作。但是,我该如何使用链接呢? 问题答案: 内联事件处理程序 以最简单的方式,您可以在内联处理程序中使用该函数。 高级事件处理 但是通常情况下,您希望将HTML和Javascript分开,

  • 在本机应用程序中,当警报或对话框打开时,状态栏和系统导航栏变为透明,但在颤振系统中,导航栏保持白色。。请帮我实现这个目标。 在本机应用程序中: (https://i.stack.imgur.com/al54d.jpg) 在颤动中: (https://i.stack.imgur.com/E3PjM.jpg)

  • 问题内容: 我有一个jQuery UI对话框,当单击特定元素时会显示该对话框。如果在那些触发元素或对话框本身之外的任何地方都单击了鼠标,我想关闭对话框。 这是打开对话框的代码: 如果我取消最后一部分的注释,该对话框将永远不会打开。我认为这是因为打开对话框的同一点击再次将其关闭。 最后的工作代码 注意:这是使用 jQuery外部事件插件 问题答案: 查看jQuery Outside Events插件

  • 我需要将导航栏链接更改为白色,并在导航栏上留出空间。我已经为此编写了代码,但我似乎不明白为什么/在哪里它一直被覆盖。导航栏的背景是一个图像,链接似乎变为白色,而图像不在其中,那么有没有办法修复这个问题并将图像保留在背景中? 有人能帮我理解我做错了什么吗?

  • 主要内容:实例,导航按钮图标,实例,定位图标,激活按钮,实例,实例,更多实例导航栏是由一组水平排列的链接组成,通常包含在头部或尾部内。 默认情况下,导航栏中的链接将自动变成按钮(不需要 data-role="button")。 使用 data-role="navbar" 属性来定义导航栏: 实例 <div data-role="header"> <div data-role="navbar"> <ul> <li><a href="#anylink">首页</a></li>