this 用法之作用域:$("option:selected",this)

来源:互联网 发布:帝国cms整合ck 编辑:程序博客网 时间:2024/04/30 08:22

$("#select1").dblclick(function(){

 var$option=$("option:selected",this);//这里是什么意思?$option.appentTo($("#select2")); })

$()有2个参数,一个是选择器,一个是作用域。要和$("xxxx,xxx")区分。通常意义下的$('xxxx')其实是默认了第二个作用域。完整说应该是$('xxxx',document)

$('#select2').dblclick(function(){

   $("option:selected",this).appendTo('#select1');

});

以上等同于:

$('#select2').dblclick(function(){

   $("#select2 option:selected").appendTo('#select1');

});

0 0
原创粉丝点击