• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Style] JS - filter 속성 - 이미지필터효과 (= filter속성 = 필터속성) ※ 흑백이미지만들기

목차

  1. filter 예제 - 이미지 필터 효과 설정
  2. filter 정의
  3. filter 구문
  4. filter 예제 - 이미지 필터 효과 반환

 

filter 예제 - 이미지 필터 효과 설정

 

<button onclick="homzzang()">클릭</button><br><br>


<img id="hz" src="https://source.unsplash.com/random" alt="이미지" width="300" height="300">


<script>

function homzzang() {

  document.getElementById("hz").style.filter = "grayscale(100%)";

}

</script>

 

 

filter 정의

 

요소 (보통 <img>)에 대한 시각 효과 (예: 흐림/채도 등) 설정/반환.

 



Edge 13 + 주요 최신 브라우저 지원.

단, IE 지원 X

 

 

filter 구문

 

반환

object.style.filter

 

설정

object.style.filter = "none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia()"

 


[속성값]

 

CSS filter 속성 참고: https://homzzang.com/b/css-330

 

 

filter 예제 - 이미지 필터 효과 반환

 

<button onclick="homzzang()">클릭</button><br><br>


<img id="hz" src="https://source.unsplash.com/random" alt="이미지" width="300" height="300" style="filter:grayscale(100%)">


<script>

function homzzang() {

  alert(document.getElementById("hz").style.filter);

}

</script>

 

 


분류 제목
DOM_Style JS - hyphens -
DOM_Style JS - icon -
DOM_Style JS - imageOrientation -
DOM_Style JS - isolation -
DOM_Style JS - justifyContent 속성 - flex 항목 세로 정렬 설정/반환 (= justifyConte…
DOM_Style JS - left 속성 - 왼쪽기준 (= left속성 = 좌측기준 = 레프트속성, 상속 X)
DOM_Style JS - letterSpacing 속성 ★ - 글자 간격 반환/설정 ( 텍스트사이띄우기 = 문자 간격 = 글…
DOM_Style JS - lineHeight 속성 ★ - 텍스트라인높이 (= line-height속성 = 텍스트줄높이 = 글…
DOM_Style JS - listStyle -
DOM_Style JS - listStyleImage -
DOM_Style JS - listStylePosition -
DOM_Style JS - listStyleType 속성 - 리스트 마커 모양 (= listStyleType속성 / 리스트스타…
DOM_Style JS - margin -
DOM_Style JS - marginBottom -
DOM_Style JS - marginLeft -
DOM_Style JS - marginRight -
DOM_Style JS - marginTop -
DOM_Style JS - maxHeight -
DOM_Style JS - maxWidth 속성 - 가로최대너비 (= 가로최대길이)
DOM_Style JS - minHeight -
6/10
목록
찾아주셔서 감사합니다. Since 2012