첫 번째 버전 :이 버전 중 jQuery에서 더 뛰어난 것은 어느 것입니까?
$(".myClass").focus(function() {
var MyRef=$(this);
if (MyRef.val() == MyRef.attr("rel")) {
MyRef.val("");
}
});
$(".myClass").focusout(function() {
var MyRef=$(this);
if (MyRef.val() == "") {
MyRef.val(MyRef.attr("rel"));
}
});
두 번째 버전 :
이$(".myClass").focus(function() {
if ($(this).val() == $(this).attr("rel")) {
$(this).val("");
}
});
$(".myClass").focusout(function() {
if ($(this).val() == "") {
$(this).val($(this).attr("rel"));
}
});
그래서하지 않고 변수에 this
을 저장하거나 사용? 아니면 변화가 없습니까? 새 jQuery를 객체에게 당신이 this
에 jQuery를 방법을 적용 할 때마다 구성 할 필요가 없기 때문에 더 빨라집니다 this
을 포함하는 jQuery를 개체에 대한 참조를 저장
예! 잘못된 복사 및 붙여 넣기 :) – markzzz