<legend id='uV5fa'><style id='uV5fa'><dir id='uV5fa'><q id='uV5fa'></q></dir></style></legend>

    1. <tfoot id='uV5fa'></tfoot>

      <small id='uV5fa'></small><noframes id='uV5fa'>

      <i id='uV5fa'><tr id='uV5fa'><dt id='uV5fa'><q id='uV5fa'><span id='uV5fa'><b id='uV5fa'><form id='uV5fa'><ins id='uV5fa'></ins><ul id='uV5fa'></ul><sub id='uV5fa'></sub></form><legend id='uV5fa'></legend><bdo id='uV5fa'><pre id='uV5fa'><center id='uV5fa'></center></pre></bdo></b><th id='uV5fa'></th></span></q></dt></tr></i><div id='uV5fa'><tfoot id='uV5fa'></tfoot><dl id='uV5fa'><fieldset id='uV5fa'></fieldset></dl></div>
      • <bdo id='uV5fa'></bdo><ul id='uV5fa'></ul>

      1. javascript获取元素的标签

        javascript get element#39;s tag(javascript获取元素的标签)

          <tbody id='kADgY'></tbody>
          <bdo id='kADgY'></bdo><ul id='kADgY'></ul>

              <tfoot id='kADgY'></tfoot>
                <legend id='kADgY'><style id='kADgY'><dir id='kADgY'><q id='kADgY'></q></dir></style></legend>

                <small id='kADgY'></small><noframes id='kADgY'>

                <i id='kADgY'><tr id='kADgY'><dt id='kADgY'><q id='kADgY'><span id='kADgY'><b id='kADgY'><form id='kADgY'><ins id='kADgY'></ins><ul id='kADgY'></ul><sub id='kADgY'></sub></form><legend id='kADgY'></legend><bdo id='kADgY'><pre id='kADgY'><center id='kADgY'></center></pre></bdo></b><th id='kADgY'></th></span></q></dt></tr></i><div id='kADgY'><tfoot id='kADgY'></tfoot><dl id='kADgY'><fieldset id='kADgY'></fieldset></dl></div>
                1. 本文介绍了javascript获取元素的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设这是我的 HTML:

                  Lets say this is my HTML:

                  <div id="foo">
                  <input id="goo" value="text" />
                  <span id="boo">
                  </span>
                  </div>
                  

                  我希望能够确定哪个标签属于 html 元素.

                  I would like to be able to determine what tag belongs to a html element.

                  示例元素 id "foo" = div, "goo" = input, "boo" = span ...

                  Example element with id "foo" = div, "goo" = input, "boo" = span ...

                  所以是这样的:

                  function getTag (id) {
                     var element = document.getElementById(id);
                     return element.tag;
                  }
                  

                  推荐答案

                  HTMLElement.tagName

                  const element = document.getElementById('myImgElement');
                  console.log('Tag name: ' + element.tagName);
                  // Tag name: IMG

                  <img src="http://placekitten.com/200/200" id="myImgElement" alt="">

                  注意:它返回大写的标签.例如.<img/> 将返回 IMG.

                  NOTE: It returns tags in capitals. E.g. <img /> will return IMG.

                  这篇关于javascript获取元素的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)

                    1. <i id='zn7TK'><tr id='zn7TK'><dt id='zn7TK'><q id='zn7TK'><span id='zn7TK'><b id='zn7TK'><form id='zn7TK'><ins id='zn7TK'></ins><ul id='zn7TK'></ul><sub id='zn7TK'></sub></form><legend id='zn7TK'></legend><bdo id='zn7TK'><pre id='zn7TK'><center id='zn7TK'></center></pre></bdo></b><th id='zn7TK'></th></span></q></dt></tr></i><div id='zn7TK'><tfoot id='zn7TK'></tfoot><dl id='zn7TK'><fieldset id='zn7TK'></fieldset></dl></div>
                          <tbody id='zn7TK'></tbody>
                          <legend id='zn7TK'><style id='zn7TK'><dir id='zn7TK'><q id='zn7TK'></q></dir></style></legend>
                          • <bdo id='zn7TK'></bdo><ul id='zn7TK'></ul>
                          • <tfoot id='zn7TK'></tfoot>

                            <small id='zn7TK'></small><noframes id='zn7TK'>