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

[HTML_Objects] JS - <figure> 객체 - 독립콘텐츠표시 (= figure태그 = 피겨태그) (HTML5추가, IE9)

목차
  1. <figure> 객체 정의 - 독립콘텐츠 표시
  2. <figure> 객체 구문
  3. <figure> 객체 예제 - 접근
  4. <figure> 객체 예제 - 생성
  5. <figure> 객체 속성

 

<figure> 객체 정의 - 독립콘텐츠 표시

 

HTML <figure> 태그(요소) 의미.

 

 

<figure> 객체 구문

 

[접근]

var x = document.getElementById("요소ID");

 

[생성]

var x = document.createElement("FIGURE");

 

 

<figure> 객체 예제 - 접근

 

<figure id="hz">

  <img src="https://source.unsplash.com/random" alt="랜덤짤" width="304" height="228">

</figure>


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


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.getElementById("hz").id;

  document.getElementById("demo").innerHTML = x;

}

</script> 

 

결과보기 

 

<figure> 객체 예제 - 생성

 

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


<script>

function homzzang() {

  var x = document.createElement("FIGURE");

  x.setAttribute("id", "hz");

  document.body.appendChild(x);


  var y = document.createElement("IMG");

  y.setAttribute("src", "https://source.unsplash.com/random");

  y.setAttribute("width", "304");

  y.setAttribute("width", "228");

  y.setAttribute("alt", "랜덤짤");


  x.appendChild(y);

}

</script> 

 

결과보기 

 

<figure> 객체 속성

 

고유 속성 없음. 

 

※ <figure> 객체는 표준 속성/메서드/이벤트 지원.

 

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
게시물이 없습니다.
목록
찾아주셔서 감사합니다. Since 2012