2013-03-18 86 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