1
나는 SO jQuery: checking if the value of a field is null (empty)에서 찍은 코드jQuery : 길이를 확인하기 위해 무효화 할 수 있습니까? = 0?
var $d = $('#person_data[document_type]');
if ($d.length != 0) {
if ($d.val().length != 0) {...}
}
는 최고 중의 최고 경우 궁금 하군요?
나는
var $d = $('#person_data[document_type]');
if ($d.length) {
if ($d.val().length) {...}
}
대신 사용할 수 있습니까?
어느 것이 더 낫습니까?
물론 두 번째. – Jai
그럼 답 중에서 가장 정확한 것은 무엇입니까? :) – Haradzieniec
언제나'var $ d = $ (element) .val(); if ($ d && $ d.length) {...}'내게 더 쉬운 것처럼 보임 -> [** FIDDLE **] (http://jsfiddle.net/adeneo/MhbVt/) ... – adeneo