原来js中的this这么好用

例如

 

代码
$(document).ready(function(){

  
var DragElement=null;

  $(
"#zz").mousedown(function(){

  DragElement
=this;//这时this指的就是$("#zz")对象

  $(document).mousemove(
function(){

  如果直接$(
this).css("left")//由于是在mousemove内,这样this对象就不是$("#zz"),

  这时可以用$(DragElement).css(
"left")//这样取的就是$("#zz")

})

})

})

 

 

真是太好用了!
posted @ 2010-09-04 10:26  蓝丶 sky  阅读(368)  评论(0编辑  收藏  举报