码迷,mamicode.com
首页 > 其他好文 > 详细

动态方法getElementsByTagName()

时间:2016-02-27 16:28:47      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

代码:

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8" />
        <title>getElementsByTagName</title>
        <script type="text/javascript">
            use strict;
            window.onload = function() {
                let buttonsForTagName = document.getElementsByTagName(button);
                // 0
                alert(buttonsForTagName.length);
                document.body.innerHTML = <button id="button1">button1</button><button id="button2">button2</button><button id="button3">button3</button>;
                // 3
                alert(buttonsForTagName.length);
            }
        </script>
    </head>

    <body>
    </body>

</html>

备注:

getElementsByTagName()方法一个动态方法。

动态方法getElementsByTagName()

标签:

原文地址:http://www.cnblogs.com/loftyspirit/p/5222950.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!