标签:document char select button on() sel selector .com isp
新建html文件可以运行(jsp文件下不可运行)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: auto;
}
.d1{
width: 500px;
height: 500px;
background-color: blue;
}
.d2,.d3,.d4{
display: inline;
}
.d2{
background-color: #ccc;
}
.d3{
background-color: #FF0;
}
.d4{
background-color: red;
}
</style>
</head>
<body>
<div class="d1">
<div class="d2">div1</div><br />
<div class="d3">div2</div>
</div>
<div class="d4">div4</div><br />
<input class="btn" type="button" value="ok" />
</body>
<script src="http://code.jquery.com/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
var d2L=document.querySelector(".d2").offsetLeft;
var d2T=document.querySelector(".d2").offsetTop;
// alert(d2L+"-"+d2T);
$(".btn").click(function(){
$(".d4").css({
"position":"absolute",
"left":d2L,
"top":d2T
})
});
})
</script>
</html>
标签:document char select button on() sel selector .com isp
原文地址:http://www.cnblogs.com/jinhuan/p/6812329.html