JavaScript

[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 - captionSide -
DOM_Style JS - clear 속성 ★ - float 해제후 줄바꿈 (= 클리어속성, clear속성, 상속 X)
DOM_Style JS - clip 속성 - 이미지 일부만 노출 (= 이미지 자르기 = clip속성 = 클립속성)
DOM_Style JS - color 속성 - 글자색깔 (=글자색상=글자색깔=글자컬러 = 텍스트색깔 = 컬러속성 = colo…
DOM_Style JS - columnCount -
DOM_Style JS - columnFill -
DOM_Style JS - columnGap -
DOM_Style JS - columnRule -
DOM_Style JS - columnRuleColor -
DOM_Style JS - columnRuleStyle -
DOM_Style JS - columnRuleWidth -
DOM_Style JS - columns -
DOM_Style JS - columnSpan -
DOM_Style JS - columnWidth -
DOM_Style JS - content -
5/13
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 2
웹유틸
회원센터
홈짱닷컴 PC버전 로그인