jQuery ( ": file") 정보
jQuery jQuery ( ": file")본문
jQuery ( ": file")
설명 : 파일 형식의 모든 요소를 선택합니다.
:file은 (와) 동등합니다 [type="file"]. 다른 의사 클래스 선택기 ( ":"로 시작하는 선택기)와 마찬가지로 태그 이름이나 다른 선택자를 앞에 두는 것이 좋습니다. 그렇지 않으면 범용 선택기 ( "*")가 내포됩니다. 다른 말로 표현하면, 맨손 $( ":file" )은에 상응 $("*:file" )하므로 $( "input:file" )대신 사용해야합니다.
추가 참고 사항 :
:filejQuery 확장이며 CSS 사양의 일부가 아니기 때문에 사용하는 쿼리 :file는 기본 DOM querySelectorAll()메서드 에서 제공하는 성능 향상을 이용할 수 없습니다 . 최신 브라우저의 성능을 높이려면 [type="file"]대신 사용하십시오.
예:
모든 파일 입력을 찾습니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>file demo</title>
<style>
textarea {
height: 45px;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<form>
<input type="button" value="Input Button">
<input type="checkbox">
<input type="file">
<input type="hidden">
<input type="image">
<input type="password">
<input type="radio">
<input type="reset">
<input type="submit">
<input type="text">
<select><option>Option</option></select>
<textarea></textarea>
<button>Button</button>
</form>
<div></div>
<script>
var input = $( "input:file" ).css({
background: "yellow",
border: "3px red solid"
});
$( "div" )
.text( "For this type jQuery found " + input.length + "." )
.css( "color", "red" );
$( "form" ).submit(function( event ) {
event.preventDefault();
});
</script>
</body>
</html>
0
댓글 0개