2013-03-18 107 views
0

我有一个简单的模式窗口,当单击链接时打开,当用户单击关闭按钮(在我的小提琴中表示为红色矩形)时关闭。模式关闭按钮不起作用

Here is a link to my fiddle

这是代码:

// prize modal 
$('.modal').on('click',function(){ 
    if(!$('#prize-modal').hasClass('open')){ 
     $('#prize-modal').css('opacity',0.7); 
     if($.browser.msie){ 
     $('#prize-modal').css('opacity','null').css('display','block').addClass('open'); 
     }else { 
     $('#prize-modal').css('opacity',0).css('display','block').addClass('open').stop().animate({opacity: 1}, 500); 
     } 
    } 
    return false; 
}); 

// .close the class that you want to trigger the modal clossing 

$('.close').on('click',function(){ 
    if($.browser.msie){ 
     $('.open').css('opacity','null').css('display','none').removeClass('open'); 
    }else { 
     $('.open').stop().animate({opacity: 0}, 500,function() 
     { 
     $('.open').css('display','none').removeClass('open'); 
     }); 
    } 
}); 

我想不通为什么 “关闭” 按钮不起作用。

+0

请张贴在这个问题你的代码。 – adamb 2013-03-18 14:43:57

+0

你是否在使用jQuery 2? – j08691 2013-03-18 14:47:08

+0

@ j08691 - 我在我的原始文件中使用Jquery 1.9,但出于某种原因,当我尝试选择Jquery 1.9(从页面左上角的菜单)时,它只会从下拉列表中选择Jquery 2? – jsavage980 2013-03-18 14:50:22

回答

0
`TypeError: 'undefined' is not an object (evaluating '$.browser.msie')` 

jQuery.browser() removed

The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin . We recommend using feature detection with a library such as Modernizr.

来源:http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed

更新小提琴:http://jsfiddle.net/zwN6R/31/

+0

感谢Eric的回应!我看到它在我的小提琴中奏效,但想知道你为了使它工作而纠正了什么?非常感谢! – jsavage980 2013-03-18 15:03:31

+0

版本1.9 jQuery.browser()已被删除。为了工作,你可以使用[jQuery Migrate Plugin](https://github.com/jquery/jquery-migrate/)。 – 2013-03-18 15:05:40

+0

您好埃里克我已经包括JQuery的Migrate插件建议(包括在我的HTML的头部jQuery 1.9),但由于某种原因,它不是像我的小提琴一样工作。这里是一个链接http://www.joemsavage.com/misn_006/index.html – jsavage980 2013-03-18 15:17:15