Cualquier página web que se cargue en el navegador se puede representar mediante la interfaz del documento. Esto sirve como un punto de entrada al árbol DOM y el árbol DOM contiene todos los elementos como , , </p> <table>, <a>, etc.</p> <p>Podemos crear un objeto Document usando el constructor Document (). Hay muchas propiedades de estos objetos de documento. Una de esas propiedades es <em><strong>Enlaces</strong></em>. La propiedad links nos da una colección de todos los elementos </p> <area> y elementos <a> en un documento. Una propiedad más es la <em>largo</em> propiedad. La propiedad length nos dice el número de enlaces presentes en el <em>document.links</em> formación. Entonces el <em>document.links.length</em> declaración nos da el número de enlaces presentes en un documento.</p> <p>A continuación, el documento HTML contiene un fragmento de código JavaScript que indica la cantidad de enlaces presentes en el documento:</p> <div class="noIdeBtnDiv"> <div class="code-block"> <div class="code-container"> <div id="highlighter_370155" class="syntaxhighlighter nogutter "> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="code"> <div class="container"> <p><code class="plain"><!DOCTYPE html> </code></p> <p><code class="plain"><</code><code class="keyword">html</code><code class="plain">> </code></p> <p><code class="plain"><</code><code class="keyword">body</code><code class="plain">> </code></p> <p><code class="undefined spaces"> </code> </p> <p><code class="plain"><</code><code class="keyword">a</code> <code class="color1">href</code> <code class="plain">= </code><code class="string">"www.geeksforgeeks.org"</code><code class="plain">></</code><code class="keyword">a</code><code class="plain">> </code></p> <p><code class="plain"><</code><code class="keyword">a</code> <code class="color1">href</code><code class="plain">=</code><code class="string">"practice.geeksforgeeks.org"</code><code class="plain">></</code><code class="keyword">a</code><code class="plain">> </code></p> <p><code class="undefined spaces"> </code> </p> <p><code class="undefined spaces"> </code> </p> <p><code class="plain"><</code><code class="keyword">script</code> <code class="color1">type</code><code class="plain">=</code><code class="string">"text/javascript"</code><code class="plain">> </code></p> <p><code class="undefined spaces">  </code><code class="plain">document.write("Number of links: " +  </code></p> <p><code class="undefined spaces">                  </code><code class="plain">document.links.length); </code></p> <p><code class="plain"></</code><code class="keyword">script</code><code class="plain">> </code></p> <p><code class="undefined spaces"> </code> </p> <p><code class="plain"></</code><code class="keyword">body</code><code class="plain">> </code></p> <p><code class="plain"></</code><code class="keyword">html</code><code class="plain">> </code></p> </div> </td> </tr> </tbody> </table> </div> </div> </div> </div> <p>Producción:</p> <pre>2 </pre> </div> </div><!-- .entry-content --> </div> </article><!-- #post --> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text">Navegación de entradas</h1> <div class="nav-links"> <a href="https://www.serverblog.info/php-funcion-intlchar-isidstart-tutorialspoint-dev/" rel="prev"><span class="meta-nav">←</span> PHP | Función IntlChar :: isIDStart () – Tutorialspoint.dev</a> <a href="https://www.serverblog.info/procesamiento-de-imagenes-en-java-conjunto-12-mejora-de-contraste/" rel="next">Procesamiento de imágenes en Java | Conjunto 12 (mejora de contraste) <span class="meta-nav">→</span></a> </div><!-- .nav-links --> </nav><!-- .navigation --> <div id="comments" class="comments-area"> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title">Deja una respuesta <small><a rel="nofollow" id="cancel-comment-reply-link" href="/mostrar-la-cantidad-de-enlaces-presentes-en-un-documento-usando-javascript/#respond" style="display:none;">Cancelar la respuesta</a></small></h3><form action="https://www.serverblog.info/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate><p class="comment-notes"><span id="email-notes">Tu dirección de correo electrónico no será publicada.</span> Los campos obligatorios están marcados con <span class="required">*</span></p><p class="comment-form-comment"><label for="comment">Comentario</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p><p class="comment-form-author"><label for="author">Nombre <span class="required">*</span></label> <input id="author" name="author" type="text" value="" size="30" maxlength="245" required='required' /></p> <p class="comment-form-email"><label for="email">Correo electrónico <span class="required">*</span></label> <input id="email" name="email" type="email" value="" size="30" maxlength="100" aria-describedby="email-notes" required='required' /></p> <p class="comment-form-url"><label for="url">Web</label> <input id="url" name="url" type="url" value="" size="30" maxlength="200" /></p> <p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">Guarda mi nombre, correo electrónico y web en este navegador para la próxima vez que comente.</label></p> <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Publicar el comentario" /> <input type='hidden' name='comment_post_ID' value='3012' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> </p></form> </div><!-- #respond --> </div><!-- #comments --> </div><!-- #content --> <div id="tertiary" class="sidebar-container" role="complementary"> <div class="sidebar-inner"> <div class="widget-area" id="sidebar-widgets"> <aside id="categories-2" class="widget widget_categories"><h3 class="widget-title">Categorías</h3> <ul> <li class="cat-item cat-item-4"><a href="https://www.serverblog.info/anguage-cpp/">anguage cpp</a> </li> <li class="cat-item cat-item-2"><a href="https://www.serverblog.info/java/">Java</a> </li> <li class="cat-item cat-item-5"><a href="https://www.serverblog.info/javascript-js/">JAVASCRIPT (JS)</a> </li> <li class="cat-item cat-item-3"><a href="https://www.serverblog.info/language-c/">language c</a> </li> <li class="cat-item cat-item-6"><a href="https://www.serverblog.info/php/">PHP</a> </li> <li class="cat-item cat-item-7"><a href="https://www.serverblog.info/piton/">Pitón</a> </li> <li class="cat-item cat-item-1"><a href="https://www.serverblog.info/uncategorized/">Uncategorized</a> </li> </ul> </aside> <aside id="wpp-2" class="widget popular-posts"> <div class="wpp-widget-placeholder" data-widget-id="wpp-2"></div> </aside> </div><!-- .widget-area --> </div><!-- .sidebar-inner --> </div><!-- #tertiary --> </div><!-- #primary --> </div><!-- #main --> <footer id="colophon" class="site-footer" role="contentinfo"> <div class="footer-bg clearfix"> <div class="widget-wrap"> <div id="secondary" class="sidebar-container" role="complementary"> <div class="widget-area" id="footer-widgets"> <aside id="search-2" class="widget widget_search"><form role="search" method="get" class="search-form" action="https://www.serverblog.info/"> <label> <span class="screen-reader-text">Buscar por:</span> <input type="search" class="search-field" placeholder="Buscar..." value="" name="s" title="Buscar por:" /> </label> <input type="submit" class="search-submit" value="Buscar" /> </form></aside> <aside id="recent-posts-2" class="widget widget_recent_entries"> <h3 class="widget-title">Entradas recientes</h3> <ul> <li> <a href="https://www.serverblog.info/https-dhtrust-org-top-10-esta-conectado-a-wi-fi-pero-no-tiene-acceso-a-internet-en-windows-que-hacer/">https://dhtrust.org/top-10/esta-conectado-a-wi-fi-pero-no-tiene-acceso-a-internet-en-windows-que-hacer/</a> </li> <li> <a href="https://www.serverblog.info/https-dhtrust-org-como-cuanto-cuesta-reemplazar-una-fuga-de-vacio/">https://dhtrust.org/como/cuanto-cuesta-reemplazar-una-fuga-de-vacio/</a> </li> <li> <a href="https://www.serverblog.info/https-dhtrust-org-como-hercules-tiene-una-cicatriz-answerstoall/">https://dhtrust.org/como/hercules-tiene-una-cicatriz-answerstoall/</a> </li> <li> <a href="https://www.serverblog.info/https-dhtrust-org-comparaciones-que-es-hdr-para-televisores-y-por-que-deberia-importarle/">https://dhtrust.org/comparaciones/que-es-hdr-para-televisores-y-por-que-deberia-importarle/</a> </li> <li> <a href="https://www.serverblog.info/https-dhtrust-org-top-10-mas-de-100-ideas-de-mini-proyectos-basados-%e2%80%8b%e2%80%8ben-microcontroladores-para-estudiantes-de-ingenieria/">https://dhtrust.org/top-10/mas-de-100-ideas-de-mini-proyectos-basados-%e2%80%8b%e2%80%8ben-microcontroladores-para-estudiantes-de-ingenieria /</a> </li> </ul> </aside><aside id="recent-comments-2" class="widget widget_recent_comments"><h3 class="widget-title">Comentarios recientes</h3><ul id="recentcomments"><li class="recentcomments"><span class="comment-author-link">A WordPress Commenter</span> en <a href="https://www.serverblog.info/hello-world/#comment-1">Hello world!</a></li></ul></aside> </div><!-- .widget-area --> </div><!-- #secondary --> </div> </div> <div class="site-info"> <div class="copyright"> Copyright © serverblog.info </div> <div class="credit-info"> <a href="http://es.wordpress.org/" title="Plataforma semántica de publicación personal"> Funciona con WordPress </a> , tema <a href="http://www.templatesnext.org/i-max/" title="Tema WordPress multipropósito WooCommerce" rel="designer"> i-max </a> por TemplatesNext. </div> </div><!-- .site-info --> </footer><!-- #colophon --> </div><!-- #page --> <script type='text/javascript' src='https://www.serverblog.info/wp-includes/js/comment-reply.min.js?ver=5.7.3' id='comment-reply-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-includes/js/imagesloaded.min.js?ver=4.1.4' id='imagesloaded-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-includes/js/masonry.min.js?ver=4.2.2' id='masonry-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-includes/js/jquery/jquery.masonry.min.js?ver=3.1.2b' id='jquery-masonry-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/js/waypoints.min.js?ver=2014-01-13' id='imax-waypoint-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/js/jquery.sidr.min.js?ver=2014-01-13' id='imax-sidr-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/js/owl.carousel.min.js?ver=2014-01-13' id='owl-carousel-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/js/functions.js?ver=2018-04-24' id='imax-script-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/inc/responsive-menu/js/jquery.transit.min.js?ver=2017-03-16' id='jquery.transit-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/inc/responsive-menu/js/jquery.sidr.js?ver=2017-03-16' id='sidr-js'></script> <script type='text/javascript' id='wprmenu.js-js-extra'> /* <![CDATA[ */ var wprmenu = {"zooming":"yes","from_width":"1069","swipe":"yes"}; /* ]]> */ </script> <script type='text/javascript' src='https://www.serverblog.info/wp-content/themes/i-max/inc/responsive-menu/js/wprmenu.js?ver=2017-03-16' id='wprmenu.js-js'></script> <script type='text/javascript' src='https://www.serverblog.info/wp-includes/js/wp-embed.min.js?ver=5.7.3' id='wp-embed-js'></script> <div id="wprmenu_bar" class="wprmenu_bar"> <div class="wprmenu-inner"> <div class="wprmenu_icon"> <span class="wprmenu_ic_1"></span> <span class="wprmenu_ic_2"></span> <span class="wprmenu_ic_3"></span> </div> <div class="menu_title"> MENÚ </div> </div> </div> <div id="wprmenu_menu" class="wprmenu_levels top wprmenu_custom_icons"> <ul id="wprmenu_menu_ul"> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-74"><a href="https://www.serverblog.info/anguage-cpp/">anguage cpp</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-75"><a href="https://www.serverblog.info/java/">Java</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-76"><a href="https://www.serverblog.info/javascript-js/">JAVASCRIPT (JS)</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-77"><a href="https://www.serverblog.info/language-c/">language c</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-78"><a href="https://www.serverblog.info/php/">PHP</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-79"><a href="https://www.serverblog.info/piton/">Pitón</a></li> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-80"><a href="https://www.serverblog.info/uncategorized/">variado</a></li> </ul> <div class="wpr_search"> <form role="search" method="get" class="wpr-search-form" action="https://www.serverblog.info"><label><input type="search" class="wpr-search-field" placeholder=" Buscar...." value="" name="s" title="Search for:"></label></form> </div> </div> </body> </html>