
例如
<a href=javascript:" id="color">我是颜色</a>我要给这个添加box-shadow效果
两种方法实现,一个原生js的和一个jquery
原生方法实现
function $(id){
return document.getElementById(id)
}
color.style.boxShadow= "10px 10px 5px #f00"//添加阴影
jquery 实现
$("#color")..css('box-shadow',"10px 10px 5px #f00")//添加阴影
<!DOCTYPE html><html>
<head>
<meta content="text/html charset=gb2312" http-equiv="Content-Type">
<title>文哥讨厌IE</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
.box-shadow{
box-shadow: 10px 10px 10px 10px red
}
.obj{
border-radius:100px
width:100px
height:100px
margin:50px auto
background:#eee
}
</style>
</head>
<body>
<div class="obj" ></div>
<script type="text/javascript">
$(document).ready(function(){
$(".obj").mouseover(function(){
$(".obj").addClass("box-shadow")
})
$(".obj").mouseout(function(){
$(".obj").removeClass("box-shadow")
})
})
</script>
</body>
</html>
x.style.box-shadow=x.style.boxShadowx.style.border-radius=x.style.borderRadius
依次类推
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)