久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='qKoT8'><tr id='qKoT8'><dt id='qKoT8'><q id='qKoT8'><span id='qKoT8'><b id='qKoT8'><form id='qKoT8'><ins id='qKoT8'></ins><ul id='qKoT8'></ul><sub id='qKoT8'></sub></form><legend id='qKoT8'></legend><bdo id='qKoT8'><pre id='qKoT8'><center id='qKoT8'></center></pre></bdo></b><th id='qKoT8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qKoT8'><tfoot id='qKoT8'></tfoot><dl id='qKoT8'><fieldset id='qKoT8'></fieldset></dl></div>
  • <legend id='qKoT8'><style id='qKoT8'><dir id='qKoT8'><q id='qKoT8'></q></dir></style></legend>

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

      <bdo id='qKoT8'></bdo><ul id='qKoT8'></ul>

    1. <tfoot id='qKoT8'></tfoot>
      1. 使用jQuery獲取元素的所有屬性

        Get all attributes of an element using jQuery(使用jQuery獲取元素的所有屬性)
        • <legend id='LbNms'><style id='LbNms'><dir id='LbNms'><q id='LbNms'></q></dir></style></legend>

              <tbody id='LbNms'></tbody>
              • <bdo id='LbNms'></bdo><ul id='LbNms'></ul>

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

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

                  本文介紹了使用jQuery獲取元素的所有屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試遍歷一個元素并獲取該元素的所有屬性以輸出它們,例如,一個標簽可能有 3 個或更多屬性,我不知道,我需要獲取這些屬性的名稱和值.我的想法是這樣的:

                  $(this).attr().each(function(index, element) {var name = $(this).name;var 值 = $(this).value;//用名稱和值做一些事情...});

                  誰能告訴我這是否可行,如果可行,正確的語法是什么?

                  解決方案

                  attributes 屬性包含所有這些:

                  $(this).each(function() {$.each(this.attributes, function() {//this.attributes 不是一個普通的對象,而是一個數組//屬性節點,包含名稱和值如果(this.specified){console.log(this.name, this.value);}});});

                  <小時>

                  您還可以做的是擴展 .attr 以便您可以像 .attr() 一樣調用它來獲取所有屬性的普通對象:

                  (函數(舊) {$.fn.attr = 函數() {if(arguments.length === 0) {如果(this.length === 0){返回空值;}變量 obj = {};$.each(this[0].attributes, function() {如果(this.specified){obj[this.name] = this.value;}});返回對象;}返回 old.apply(this, arguments);};})($.fn.attr);

                  用法:

                  var $div = $("

                  I am trying to go through an element and get all the attributes of that element to output them, for example an tag may have 3 or more attributes, unknown to me and I need to get the names and values of these attributes. I was thinking something along the lines of:

                  $(this).attr().each(function(index, element) {
                      var name = $(this).name;
                      var value = $(this).value;
                      //Do something with name and value...
                  });
                  

                  Could anyone tell me if this is even possible, and if so what the correct syntax would be?

                  解決方案

                  The attributes property contains them all:

                  $(this).each(function() {
                    $.each(this.attributes, function() {
                      // this.attributes is not a plain object, but an array
                      // of attribute nodes, which contain both the name and value
                      if(this.specified) {
                        console.log(this.name, this.value);
                      }
                    });
                  });
                  


                  What you can also do is extending .attr so that you can call it like .attr() to get a plain object of all attributes:

                  (function(old) {
                    $.fn.attr = function() {
                      if(arguments.length === 0) {
                        if(this.length === 0) {
                          return null;
                        }
                  
                        var obj = {};
                        $.each(this[0].attributes, function() {
                          if(this.specified) {
                            obj[this.name] = this.value;
                          }
                        });
                        return obj;
                      }
                  
                      return old.apply(this, arguments);
                    };
                  })($.fn.attr);
                  

                  Usage:

                  var $div = $("<div data-a='1' id='b'>");
                  $div.attr();  // { "data-a": "1", "id": "b" }
                  

                  這篇關于使用jQuery獲取元素的所有屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                    <legend id='ugpjF'><style id='ugpjF'><dir id='ugpjF'><q id='ugpjF'></q></dir></style></legend><tfoot id='ugpjF'></tfoot>
                  1. <small id='ugpjF'></small><noframes id='ugpjF'>

                          <tbody id='ugpjF'></tbody>
                        • <i id='ugpjF'><tr id='ugpjF'><dt id='ugpjF'><q id='ugpjF'><span id='ugpjF'><b id='ugpjF'><form id='ugpjF'><ins id='ugpjF'></ins><ul id='ugpjF'></ul><sub id='ugpjF'></sub></form><legend id='ugpjF'></legend><bdo id='ugpjF'><pre id='ugpjF'><center id='ugpjF'></center></pre></bdo></b><th id='ugpjF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ugpjF'><tfoot id='ugpjF'></tfoot><dl id='ugpjF'><fieldset id='ugpjF'></fieldset></dl></div>
                          • <bdo id='ugpjF'></bdo><ul id='ugpjF'></ul>
                            主站蜘蛛池模板: 久久精品国产亚洲 | 国产xxxx在线 | 日韩欧美国产精品 | 国产原创在线观看 | 国产精彩视频在线观看 | 欧美精品1区 | 国产免费一区二区三区 | 一级毛片视频在线观看 | 不卡在线视频 | 作爱视频免费观看 | 欧美激情精品久久久久久 | 亚州春色 | 99久久久国产精品免费消防器 | 一级在线毛片 | 黄色成人免费在线观看 | 国产一区二区免费电影 | 91一区二区三区在线观看 | 99爱视频 | 老子午夜影院 | 亚洲男人网 | 国产成人在线视频免费观看 | 日韩一级一区 | 久草视频在线播放 | 国内精品一区二区 | 99久久视频| 国产激情在线 | 亚洲最大的成人网 | 国产日韩欧美一区二区 | 国产专区在线 | 91日韩| 丝袜天堂| 九九亚洲精品 | 午夜三级视频 | 日韩在线成人 | 欧美aaaaa | 三区在线观看 | 国产成人精品一区二区三区网站观看 | 亚洲国产精品成人久久久 | 国产一区二区三区四区三区四 | 精品久久久999 | 日本不卡视频在线播放 |