document.links 예제
<img src ="aaa.gif" width="100" height="100" alt="aaa" usemap ="#hzmap"> <map name="hzmap"> <area shape="rect" coords="204,3,259,20" href="aaa.htm" alt="aaa"> <area shape="circle" coords="269,2,323,20" href="bbb.htm" alt="bbb"> </map> <ul> <li><a href="https://homzzang.com/b/html">HTML</a></li> <li><a href="https://homzzang.com/b/css">CSS</a></li> </ul> <button onclick="homzzang()">클릭</button> <p id="demo"></p> <script> function homzzang() { var x = document.links.length; document.getElementById("demo").innerHTML = x; } </script> 결과보기
<img src ="aaa.gif" width="100" height="100" alt="aaa" usemap ="#hzmap">
<map name="hzmap">
<area shape="rect" coords="204,3,259,20" href="aaa.htm" alt="aaa">
<area shape="circle" coords="269,2,323,20" href="bbb.htm" alt="bbb">
</map>
<ul>
<li><a href="https://homzzang.com/b/html">HTML</a></li>
<li><a href="https://homzzang.com/b/css">CSS</a></li>
</ul>
<button onclick="homzzang()">클릭</button>
<p id="demo"></p>
<script>
function homzzang() {
var x = document.links.length;
document.getElementById("demo").innerHTML = x;
}
</script>
결과보기
결과값: 4