var fileFlag = false; $("input[name='uploadfile']").each(function(){ if($(this).val()! ="") { fileflag = true; return false; } }); if(fileFlag) { alert("The file has been selected") ; }
As long as fileFlag is true, you can exit the each loop and there is no need to judge the remaining input. Use return false in each to exit the loop, use return true to end the current loop and proceed to the next loop.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn