pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

      1. <legend id='s0INK'><style id='s0INK'><dir id='s0INK'><q id='s0INK'></q></dir></style></legend>

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

      2. 使用getAttribute(),還是不使用getAttribute():這是個(gè)問(wèn)

        To use getAttribute(), or not to use getAttribute(): that is the question(使用getAttribute(),還是不使用getAttribute():這是個(gè)問(wèn)題)
          <i id='a51yJ'><tr id='a51yJ'><dt id='a51yJ'><q id='a51yJ'><span id='a51yJ'><b id='a51yJ'><form id='a51yJ'><ins id='a51yJ'></ins><ul id='a51yJ'></ul><sub id='a51yJ'></sub></form><legend id='a51yJ'></legend><bdo id='a51yJ'><pre id='a51yJ'><center id='a51yJ'></center></pre></bdo></b><th id='a51yJ'></th></span></q></dt></tr></i><div class="bprb5vx" id='a51yJ'><tfoot id='a51yJ'></tfoot><dl id='a51yJ'><fieldset id='a51yJ'></fieldset></dl></div>

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

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

              • <legend id='a51yJ'><style id='a51yJ'><dir id='a51yJ'><q id='a51yJ'></q></dir></style></legend>

                <tfoot id='a51yJ'></tfoot>
                • 本文介紹了使用getAttribute(),還是不使用getAttribute():這是個(gè)問(wèn)題的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  可能重復(fù):
                  JavaScript setAttribute vs .attribute=
                  javascript dom,如何處理特殊屬性"與屬性相比?

                  很多時(shí)候,在論壇或諸如 Usenet 之類(lèi)的地方,一些人(在批評(píng)我的代碼時(shí))告訴我,而不是說(shuō),例如 var link = a.href 我應(yīng)該使用 var link = a.getAttribute('href'); 代替.并在想要賦值時(shí)使用它的補(bǔ)充setAttribute().

                  Many times, in forums or places such as Usenet I have been told by some (when criticizing my code) that instead of saying, for example var link = a.href I should use var link = a.getAttribute('href'); instead. And use its complementary setAttribute() when wanting to assign.

                  他們說(shuō)這是正確的做法,我錯(cuò)了,等等等等……我通常不會(huì)注意那些.當(dāng)我問(wèn)為什么沒(méi)有人給出真正的答案時(shí).

                  They say it is the correct way to do it, that I am wrong, blah blah blah... I don’t normally pay any attention to those. And when I ask why nobody gives a real answer.

                  現(xiàn)在我很好奇在哪種情況下使用一種或另一種更合適.

                  Now I am curious about in which cases it would be more suitable to use one or another.

                  在什么情況下用 var link = a.getAttribute('href'); 代替 var link = a.href 更合適?
                  在什么情況下我應(yīng)該使用 setAttribute() 來(lái)分配而不是直接通過(guò)其標(biāo)識(shí)符為成員分配值?即:`a.href = 'someURL';

                  In what cases would be more suitable to say var link = a.getAttribute('href'); instead of var link = a.href?
                  And in what cases shoulw I use setAttribute() to assign instead of assigning a value to a member directly by its identifier? i.e: `a.href = 'someURL';

                  推薦答案

                  每當(dāng)有人推薦一種做法時(shí),他們應(yīng)該始終證明該建議的合理性.

                  Whenever someone recommends a practice they should always justify the advice.

                  不使用 getAttributesetAttribute 的原因比 IE 版本高達(dá)并包括 8 至少在這些 DOM 方法的實(shí)現(xiàn)中存在錯(cuò)誤.此外,瀏覽器在如何更改 DOM 屬性以響應(yīng) get/setAttribute 的使用方面也存在差異.

                  Reasons for not using getAttribute and setAttribute are than IE versions up to and including 8 at least have bugs in their implementation of those DOM methods. Also, browsers have differences in how they change DOM properties in response to the use of get/setAttribute.

                  但是,瀏覽器在 DOM 屬性方面非常一致,因此如果使用 DOM 屬性,編寫(xiě)跨瀏覽器代碼要簡(jiǎn)單得多.唯一需要注意的是,一些瀏覽器不會(huì)為非標(biāo)準(zhǔn) HTML 屬性創(chuàng)建 DOM 屬性,但它們都會(huì)使用屬性來(lái)設(shè)置它們.

                  However, browsers are remarkably consistent in regard to DOM properties, so it is much simpler to write cross browser code if you use DOM properties. The only caveat is that some browsers do not create DOM properties for non-standard HTML attributes, but they will all set them using properties.

                  另外一個(gè)好處是 DOM 屬性訪問(wèn)比使用函數(shù)調(diào)用 get/setAttribute 快得多.

                  An added bonus is that DOM property access is much faster than using a function call to get/setAttribute.

                  HTML5 正試圖將其中一些行為標(biāo)準(zhǔn)化,但 HTML5 的問(wèn)題在于它不是 W3C 標(biāo)準(zhǔn)(而且可能永遠(yuǎn)不會(huì)是),它是嘗試的活規(guī)范"不僅要記錄瀏覽器的功能(或多或少),還要記錄其作者希望他們做什么而不區(qū)分兩者.因此,雖然它作為一種竣工"規(guī)范和愿望清單很有幫助,但作為標(biāo)準(zhǔn)卻毫無(wú)用處.

                  HTML5 is attempting to standardise some of these behaviours, but the problem with HTML5 is that it is not a W3C standard (and may never be) and that it is a "living specification" that attempts to not only document what browsers do (more or less) but also what its authors would like them to do without distinguishing between the two. So while it is helpful as a kind of "as built" specification plus wish list, it is quite useless as a standard.

                  W3C 已經(jīng)發(fā)布 HTML 5 規(guī)范 有一段時(shí)間了(包括編號(hào)版本和列表更改),并且 WHATWG 還發(fā)布 HTML 和 DOM 標(biāo)準(zhǔn)幾乎每天更新,但沒(méi)有說(shuō)明發(fā)生了什么變化.一個(gè)或另一個(gè)最終可能會(huì)放棄.

                  The W3C has been publishing HTML 5 specifications for a while now (including numbered versions and lists of changes), and the WHATWG also publishes HTML and DOM standards with almost daily updates but without indicating what has changed. One or the other may give up eventually.

                  這篇關(guān)于使用getAttribute(),還是不使用getAttribute():這是個(gè)問(wèn)題的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項(xiàng)目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數(shù)據(jù)更新 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 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動(dòng)態(tài)元素 - Angular 2 amp;離子2)
                  • <bdo id='vqYA0'></bdo><ul id='vqYA0'></ul>

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

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

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

                            <tbody id='vqYA0'></tbody>
                          <tfoot id='vqYA0'></tfoot>
                            主站蜘蛛池模板: 聚天冬氨酸,亚氨基二琥珀酸四钠,PASP,IDS - 远联化工 | CCE素质教育博览会 | CCE素博会 | 教育展 | 美育展 | 科教展 | 素质教育展 | 浙江筋膜枪-按摩仪厂家-制造商-肩颈按摩仪哪家好-温州市合喜电子科技有限公司 | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 异噻唑啉酮-均三嗪-三丹油-1227-中北杀菌剂厂家 | 集菌仪厂家_全封闭_封闭式_智能智能集菌仪厂家-上海郓曹 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 黑龙江京科脑康医院-哈尔滨精神病医院哪家好_哈尔滨精神科医院排名_黑龙江精神心理病专科医院 | 数年网路-免费在线工具您的在线工具箱-shuyear.com | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 大行程影像测量仪-探针型影像测量仪-增强型影像测量仪|首丰百科 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 气力输送设备_料封泵_仓泵_散装机_气化板_压力释放阀-河南锐驰机械设备有限公司 | 北京发电车出租-发电机租赁公司-柴油发电机厂家 - 北京明旺盛安机电设备有限公司 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | R507制冷剂,R22/R152a制冷剂厂家-浙江瀚凯制冷科技有限公司 | RV减速机-蜗轮蜗杆减速机-洗车机减速机-减速机厂家-艾思捷 | 玉米深加工机械,玉米加工设备,玉米加工机械等玉米深加工设备制造商-河南成立粮油机械有限公司 | 我爱古诗词_古诗词名句赏析学习平台 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 幂简集成 - 品种超全的API接口平台, 一站搜索、试用、集成国内外API接口 | 保定市泰宏机械制造厂-河北铸件厂-铸造厂-铸件加工-河北大件加工 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 石家庄律师_石家庄刑事辩护律师_石家庄取保候审-河北万垚律师事务所 | 电动高尔夫球车|电动观光车|电动巡逻车|电动越野车厂家-绿友机械集团股份有限公司 | 乳化沥青设备_改性沥青设备_沥青加温罐_德州市昊通路桥工程有限公司 | 陕西安玻璃自动感应门-自动重叠门-磁悬浮平开门厂家【捷申达门业】 | 阳光1号桔柚_无核沃柑_柑橘新品种枝条苗木批发 - 苧金网 | H型钢切割机,相贯线切割机,数控钻床,数控平面钻,钢结构设备,槽钢切割机,角钢切割机,翻转机,拼焊矫一体机 | LOGO设计_品牌设计_VI设计 - 特创易 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | 混合气体腐蚀试验箱_盐雾/硫化氢/气体腐蚀试验箱厂家-北京中科博达 | 机器视觉检测系统-视觉检测系统-机器视觉系统-ccd检测系统-视觉控制器-视控一体机 -海克易邦 | 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 成都离婚律师|成都结婚律师|成都离婚财产分割律师|成都律师-成都离婚律师网 | 定量包装机,颗粒定量包装机,粉剂定量包装机,背封颗粒包装机,定量灌装机-上海铸衡电子科技有限公司 | MTK核心板|MTK开发板|MTK模块|4G核心板|4G模块|5G核心板|5G模块|安卓核心板|安卓模块|高通核心板-深圳市新移科技有限公司 | 定量包装机,颗粒定量包装机,粉剂定量包装机,背封颗粒包装机,定量灌装机-上海铸衡电子科技有限公司 | 顺辉瓷砖-大国品牌-中国顺辉| 二手回收公司_销毁处理公司_设备回收公司-找回收信息网 |