Lấy chiều dài – rộng của client trong jquery


<div>
<style>
#event_obj_left{
background-color:gray;
border:1px solid black;
float:left;
width:200px;
height:200px;
}
#event_obj_right{
border:1px solid black;
float:left;
margin-left:50px;
width:200px;
height:200px;
}
</style>
<script type=”text/javascript”>
$(document).ready(function(){
$(“#event_obj_left”).mousemove(function(e){
$(“#page_x”).html(e.pageX); //Lay chieu rong cua thanh phan
$(“#page_y”).html(e.pageY); //Lay chieu dai cua thanh phan
$(“#client_x”).html(e.clientX); //Lay chieu rong cua trinh duyet
$(“#client_y”).html(e.clientY); //Lay chieu dai cua trinh duyet
$(“#screen_x”).html(e.screenX); //Lay chieu rong cua man hinh
$(“#screen_y”).html(e.screenY); //Lay chieu dai cua man hinh
});
});
</script>
<div>
<div id=”event_obj_left”></div>
<div id=”event_obj_right”>
<span>pageX:
<span id=”page_x”>0</span>,
pageY: <span id=”page_y”>0</span></span>
<span>clientX: <span id=”client_x”>0</span>,
clientY: <span id=”client_y”>0</span></span>
<span>screenX: <span id=”screen_x”>0</span>,
screenY: <span id=”screen_y”>0</span></span>
</div> <div style=”clear:both;”></div>
</div> </div>

Advertisements

Để lại comment đê!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s