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

[DOM_Style] JS - fontStyle 속성 - 글자모양 (= font-style속성 = 글씨체모양 = 글씨모양 = 글자모양 = 서체모양 = 글꼴모양 = 폰트스타일) + (이탤릭체, 기울임체) (상속 O)

fontStyle 예제 

 

<p id="hz">홈짱닷컴 Homzzang.com</p>


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

 

<script>

function homzzang() {

  document.getElementById("hz").style.fontStyle = "italic";

}

</script>

 

결과보기

 

 

fontStyle 정의 

 

글자 스타일 반환/설정.

 


 

1.

기본값: normal

 

2.

모든 브라우저 지원.


 

 

fontStyle 구문 

 

[반환] 

object.style.fontStyle

 

[설정]

object.style.fontStyle = "속성값"

 


 

[속성값]

 

normal
일반 폰트 (기본값)
 
italic
이탤릭체
 
oblique
기울임체
 
initial

이 속성의 기본값으로 설정.

 
inherit

부모 요소의 스타일을 상속 

 


 

[반환값]

요소에서 텍스트의 글꼴 스타일을 나타내는 문자열.

 

 

 

fontStyle 예제 - select 선택값으로 폰트스타일 지정

 

<p id="hz">홈짱닷컴 Homzzang.com</p>


<select onchange="homzzang(this);" size="3">

  <option>normal</option>

  <option>italic</option>

  <option>oblique</option>

</select>

 

<script>

function homzzang(st) {

  var styleValue = st.options[st.selectedIndex].text;

  document.getElementById("hz").style.fontStyle = styleValue;

}

</script>

 

결과보기

 

 

fontStyle 예제 - 폰트스타일 반환

 

<p id="hz" style="font-style:italic;">홈짱닷컴 Homzzang.com</p>


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

 

<script>

function homzzang() {

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

}

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