最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How to get box-shadow programmatically under Opera - Stack Overflow

matteradmin6PV0评论

With jQuery, i'm trying to do

item.css("-o-box-shadow")

or:

item.css("box-shadow")

... but getting empty string.

Under Webkit and Gecko it works, using "-webkit" and "-moz" prefixes.

How to do it under Opera ?

I've also tried "boxShadow", but again, getting empty string.

$(".flag").css("boxShadow", "rgba(0,0,0,0.5) 4pt 4pt 7pt"); // i see, it was set
$(".flag").css("boxShadow"); // returns ""

With jQuery, i'm trying to do

item.css("-o-box-shadow")

or:

item.css("box-shadow")

... but getting empty string.

Under Webkit and Gecko it works, using "-webkit" and "-moz" prefixes.

How to do it under Opera ?

I've also tried "boxShadow", but again, getting empty string.

$(".flag").css("boxShadow", "rgba(0,0,0,0.5) 4pt 4pt 7pt"); // i see, it was set
$(".flag").css("boxShadow"); // returns ""
Share Improve this question edited Mar 3, 2011 at 14:27 thirtydot 228k50 gold badges392 silver badges354 bronze badges asked Mar 3, 2011 at 12:55 AntonALAntonAL 17.5k21 gold badges84 silver badges118 bronze badges 1
  • 1 If anybody thinks they've solved this, please provide an example where you retrieve the box-shadow property which was set via CSS. – thirtydot Commented Mar 3, 2011 at 14:09
Add a ment  | 

5 Answers 5

Reset to default 3

$('div').css('boxShadow','10px 10px 10px #FF00FF');

so: .css('boxShadow');

After searching and trying for the last fifteen minutes, I think Opera has a bug.

You just can't retrieve the box-shadow value, unless there's some obscure undocumented way.

this sounds like an issue with the way Opera has implemented boxShadow. i will see what i can dig up about why that value isn't available.

in the meantime, using your example, i think you can retrieve the entire style using $(".flag").attr("style") then split the string on the ':'.

Seeing as you want to use jQuery you can use this:

$('.item').css('boxShadow','5px 5px 6px #333333');

Example here for you :) (open in Opera)

This is likely a bug in Opera. jQuery's .css() method uses getComputedStyle || currentStyle to return CSS properties, both of which return the empty string for boxShadow.

Post a comment

comment list (0)

  1. No comments so far