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_Event JS - stalled 이벤트 - 브라우저가 미디어 데이터 사용 불가 시 실행. (= 스톨드 이벤트)
DOM_Event JS - storage -
DOM_Event JS - submit 이벤트 (= onsubmit 속성) - 제출/전송 이벤트 (= 서브밋 이벤트 = 서브미…
DOM_Event JS - suspend 이벤트 (onsuspend 속성) - 브라우저가 의도적으로 미디어 데이터 안 가져올 …
DOM_Event JS - timeupdate 이벤트 - 오디오/비디오 재생 위치 변경 발생 (= timeupdate이벤트 =…
DOM_Event JS - toggle 이벤트 (= ontoggle 속성) - <details> 요소 (열기/닫기) 시 발생 …
DOM_Event JS - touchcancel -
DOM_Event JS - touchend 이벤트 (= ontouchend 속성) - 손가락 뗄 때 이벤트 발생 (= 터치이벤…
DOM_Event JS - touchmove -
DOM_Event JS - touchstart 이벤트 - 사용자가 요소를 터치할 때 실행 (= touchstart이벤트 = 터…
DOM_Event JS - transitionend -
DOM_Event JS - unload 이벤트 (= onunload 속성) - 사용자가 웹문서 닫을때 JS실행 (= 언로드 이…
DOM_Event JS - volumechange -
DOM_Event JS - waiting -
DOM_Event JS - wheel 이벤트 (= onwheel속성) ★ - 마우스휠 스크롤 이벤트
46/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 2
웹유틸
회원센터
홈짱닷컴 PC버전 로그인