我有一个将应用some CSS shadow的div。我需要使用jQuery获取以下阴影元素:
h-shadow
,v-shadow
,blur
和spread
(以像素为单位)color
,在某些字符串中,无关紧要inset
,如果它应用于box-shadow
属性。怎么做?是否有一些特定的CSS属性,例如border-top-right-radius
来获取右上边框半径而不是使用border-radius
?
所以,示例代码:
<div id="the_div" style="box-shadow:10px 10px 5px 2px #f00 inset;">...</div>
现在有些JavaScript ......
$(function(){
$('#the_div').someFunction(); // returns the h-shadow, for example
});
答案 0 :(得分:2)
答案 1 :(得分:0)
jQuery("#divID").css("color");
这将获得颜色 - jQuery将获得您要求的css属性:jQuery CSS
答案 2 :(得分:0)
alert($('.myElementClass').css('box-shadow));
<!DOCTYPE html>
<html>
<head>
<style>
div.xxx {
position: relative;
background-color: #abc;
width: 40px;
height: 40px;
float: left;
margin: 5px;
box-shadow: 10px 10px 5px #888888;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p><button id="go">Run »</button></p>
<div class="xxx"></div>
<script>
$( "#go" ).click(function(){
alert($('.xxx').css('box-shadow'));
});
</script>
</body>
</html>
答案 3 :(得分:0)