How to check if css box-shadow is supported (jQuery)?

前端 未结 2 483
小蘑菇
小蘑菇 2021-01-20 18:36

I\'m creating a layout in full css. However, some browser (such as IE6) do not support box-shadow (.. and -webkit-box-shadow or -moz-box-shadow). I would like to check if it

2条回答
  •  醉话见心
    2021-01-20 18:58

    var check = document.createElement('div');
    
    var shadow = !!(0 + check.style['MozBoxShadow']);
    if(shadow)
       alert('moz-box-shadow available');
    

    That is the doing-it-yourself way. Other reliable way is the modernizr library, which does feature detection for you.

    http://www.modernizr.com/

    No jQuery needed at all here.

提交回复
热议问题