티스토리 뷰

728x90

Javascript 체크 방법

if( document.getElementById("videoUploadFile").files.length == 0 ){
    console.log("no files selected");
}

 

jQuery 체크 방법

if ($('#videoUploadFile')[0].files.length === 0) {
    console.log("No files selected.");
}

 

jQuery에서 $(selector)[0] 이 가지는 의미는 선택된 요소의 첫 번째 DOM 객체를 찾는 의미이다.

 

참고

https://bit.ly/3mwSKur

 

How to check if input file is empty in jQuery

Brand new to JS. I am trying to check if the file input element is empty when submitting the form with jQuery/JavaScript. I have gone through a bunch of solutions and nothing is working for me. I am

stackoverflow.com

What does $(selector)[0] mean in jQuery?

https://bit.ly/3odBWsR

 

What does $(selector)[0] mean in jQuery?

The syntax that I don't understand is this: $("#profilePhotoFileUpload")[0] I have been seeing this syntax pretty frequently and I've ignored it for a while because I never had to use it. But now...

stackoverflow.com

 

728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함