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

[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>

 

 


분류 제목
CSS_Objects JS - setProperty() 메서드 - 새 CSS속성설정 / 기존CSS속성수정 (= setPropert…
DOM JS - NodeList 속성 - 노드리스트 (= 노드목록)
Basic JS - this 키워드 ★★★★★ - 호출 방식에 따라 지시 대상 다름. (= 디스 키워드)
Functions JS - apply() 메서드 - 함수호출방법3 (= 어플라이메서드)
Functions JS - Closure - 클로저 (전역변수/지역변수/카운터)
Math JS - Math.atanh() 메서드 - 쌍곡선 아크탄젠트 (IE12 이상)
Math JS - Math.acosh() 메서드 - 쌍곡선 아크코사인 (IE12 이상)
Math JS - Math.asinh() 메서드 - 쌍곡선 아크사인 반환 (= asinh 메서드)
Math JS - Math.cbrt() 메서드 - 세제곱근
Math JS - Math.tanh() 메서드 - 쌍곡선 탄젠트 (IE12 이상)
Math JS - Math.trunc() 메서드 - 숫자의 정수부분 추출 (= trunc메서드 = 트런크메서드) (I…
Math JS - Math.cosh() 메서드 - 쌍곡선 코사인
Math JS - Math.sinh() 메서드 - 쌍곡선 사인값 (IE12 이상)
DOM_Event JS - initMouseEvent() 메서드 - 폐기예고. 마우스이벤트초기화
js JS - getRangeAt() 메서드
DOM_Document JS - styleSheets 속성 - 스타일시트집합
js JS - rules 속성 - styleSheets 객체의 속성
DOM_Event JS - cancelBubble 속성 - 부모요소로 이벤트 확산 방지 (= 상위요소로 이벤트확산취소 = 캔슬…
DOM_Event JS - composedPath() 메서드 - 이벤트객체흐름파악 (=이벤트실행객체경로파악 = 컴포우즈드패스메…
js JS - 특정요소 함수실행제외 (= 배열문자열포함검사) ★★★★★
61/67
목록
찾아주셔서 감사합니다. Since 2012