0
다음 코드에서 element.tagName은 정의되지 않습니다.element.tagName은 정의되지 않음
$('#page1').bind('pageinit', function(event) {
$('form').validate({
errorPlacement: function(error, element) {
console.log(element.tagName);
if (element.tagName === "input") {
error.insertAfter($(element).parent());
} else {
error.insertAfter(element);
}
}
});
});
그러나 이것은 작동합니다
if (element.attr("type") === “text”) {
나는 모든 입력에 error.insertAfter($(element).parent())
을 설정합니다. tagName이 작동하지 않는 이유는 무엇입니까?
:처럼,
또는 jQuery를 개체에서 기본 요소를 얻을? 여기에 jQuery와 DOM 객체가 혼합되어 있지 않습니까? – Teemu
테스트에서 대문자''INPUT ''을 사용하십시오. 또는 infact Teemu가 옳다면 jQuery와 DOM 객체가 섞여있다. 이것을 사용하십시오 -'if (element.is ('input'))' –