Để nhận số lượng neo, hãy sử dụng anchor tài sản.
Ví dụ
Bạn có thể thử chạy đoạn mã sau để nhận số lượng neo bằng JavaScript -
<!DOCTYPE html>
<html>
<body>
<a href="https://www.tutorialspoint.com/php" name="PHP">PHP</a>
<br>
<a href="https://www.tutorialspoint.com/java/" name="Java">Java</a>
<br>
<a href="https://www.tutorialspoint.com/html5/" name="HTML5">HTML</a>
<br>
<a href="https://www.tutorialspoint.com/css/" name="CSS">CSS</a>
<script>
var val = document.anchors.length;
document.write("<br>Number of anchors in the document: "+val);
</script>
</body>
</html>