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

[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 - 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 -
DOM_Style JS - minWidth -
DOM_Style JS - navDown -
DOM_Style JS - navIndex 속성 - 요소의 탭 순서를 설정/반환 (= navIndex속성 = 네브인덱스속성)
DOM_Style JS - navLeft -
DOM_Style JS - navRight -
DOM_Style JS - navUp -
DOM_Style JS - objectFit 속성 - 컨테이너에 맞게 <img>/<video> 크기 조정 방법 지정 (= ob…
DOM_Style JS - objectPosition -
DOM_Style JS - opacity 속성 - 요소의 불투명도 설정/반환 (= opacity속성 = 오패서티속성)
DOM_Style JS - order 속성 - 플렉스아이템 나열순서 (= 오더속성 = flex item order속성, IE1…
DOM_Style JS - orphans 속성 - 인쇄페이지 하단 표시할 요소의 최소줄수 설정/반환 (= orphans속성 =…
DOM_Style JS - outline -
48/67
목록
찾아주셔서 감사합니다. Since 2012