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

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

      1. <legend id='YuBjt'><style id='YuBjt'><dir id='YuBjt'><q id='YuBjt'></q></dir></style></legend>
      2. <tfoot id='YuBjt'></tfoot>
        <i id='YuBjt'><tr id='YuBjt'><dt id='YuBjt'><q id='YuBjt'><span id='YuBjt'><b id='YuBjt'><form id='YuBjt'><ins id='YuBjt'></ins><ul id='YuBjt'></ul><sub id='YuBjt'></sub></form><legend id='YuBjt'></legend><bdo id='YuBjt'><pre id='YuBjt'><center id='YuBjt'></center></pre></bdo></b><th id='YuBjt'></th></span></q></dt></tr></i><div class="uuoskay" id='YuBjt'><tfoot id='YuBjt'></tfoot><dl id='YuBjt'><fieldset id='YuBjt'></fieldset></dl></div>
          <bdo id='YuBjt'></bdo><ul id='YuBjt'></ul>

        為什么我應該在我的自定義屬性前面加上“data

        Why should I prepend my custom attributes with quot;data-quot;?(為什么我應該在我的自定義屬性前面加上“data-?)
        <tfoot id='Vt0zi'></tfoot>

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

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

          <i id='Vt0zi'><tr id='Vt0zi'><dt id='Vt0zi'><q id='Vt0zi'><span id='Vt0zi'><b id='Vt0zi'><form id='Vt0zi'><ins id='Vt0zi'></ins><ul id='Vt0zi'></ul><sub id='Vt0zi'></sub></form><legend id='Vt0zi'></legend><bdo id='Vt0zi'><pre id='Vt0zi'><center id='Vt0zi'></center></pre></bdo></b><th id='Vt0zi'></th></span></q></dt></tr></i><div class="kuss0wy" id='Vt0zi'><tfoot id='Vt0zi'></tfoot><dl id='Vt0zi'><fieldset id='Vt0zi'></fieldset></dl></div>
            <tbody id='Vt0zi'></tbody>
                • <bdo id='Vt0zi'></bdo><ul id='Vt0zi'></ul>
                  本文介紹了為什么我應該在我的自定義屬性前面加上“data-"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  所以我使用的任何自定義數據屬性都應該以data-"開頭:

                  So any custom data attribute that I use should start with "data-":

                  <li class="user" data-name="John Resig" data-city="Boston"
                       data-lang="js" data-food="Bacon">
                    <b>John says:</b> <span>Hello, how are you?</span>
                  </li>
                  

                  如果我忽略這一點,會有什么不好的事情發生嗎?即:

                  Will anything bad happen if I just ignore this? I.e.:

                  <li class="user" name="John Resig" city="Boston"
                       lang="js" food="Bacon">
                    <b>John says:</b> <span>Hello, how are you?</span>
                  </li>
                  

                  我想一件壞事是我的自定義屬性可能與具有特殊含義的 HTML 屬性沖突(例如,name),但除此之外,只寫example_text"是否有問題數據示例文本"?(它不會驗證,但誰在乎呢?)

                  I guess one bad thing is that my custom attributes could conflict with HTML attributes with special meanings (e.g., name), but aside from this, is there a problem with just writing "example_text" instead of "data-example_text"? (It won't validate, but who cares?)

                  推薦答案

                  保持自定義屬性以 data-* 為前綴有幾個好處.

                  There are several benefit for keeping custom attributes prefixed with data-*.

                  1. 它保證在以后的版本中不會與 HTML 的擴展發生任何沖突.這是一個在某種程度上已經在 HTML5 中引入的一些新屬性遇到的問題,其中現有站點使用具有相同名稱的屬性并期望不同且不兼容的自定義行為.(例如,已知 input 元素上的 required 屬性在過去曾在一些流行網站上發生過沖突)

                  1. It guarantees there will not be any clashes with extensions to HTML in future editions. This is a problem that has been encountered to some degree already with some of the new attributes introduced in HTML5, where existing sites were using attributes with the same name and expecting different and incompatible, custom behaviour. (e.g. the required attribute on input elements is known to have had some clashes on some popular websites in the past)

                  有一個方便的 DOM API,HTMLElement.dataset,用于從腳本訪問這些屬性.現在大多數瀏覽器都支持.

                  There is a convenient DOM API, HTMLElement.dataset, for accessing these attributes from scripts. It is now supported in most browsers.

                  它們清楚地表明哪些屬性是自定義屬性,哪些是標準化屬性.這不僅通過允許驗證器允許具有 data-* 的任何屬性同時仍然對其他屬性執行有用的錯誤檢查(例如捕獲拼寫錯誤)來幫助驗證器,它還有助于使源代碼的這一方面對閱讀它的人來說更加清晰,包括人們誰可以在原作者之后在網站上工作.

                  They provide a clear indication of which attributes are custom attributes, and which ones are standardised attributes. This not only helps validators by allowing them to permit any attribute with data-* while still performing useful error checking for other attributes (e.g. to catch typos), it also helps make this aspect of the source code clearer to those reading it, including people who may work on a website after the original author.

                  這篇關于為什么我應該在我的自定義屬性前面加上“data-"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  Input validation with pattern Angular 2(使用模式 Angular 2 進行輸入驗證)
                  How to change the css class name dynamically in angular 2(如何在角度2中動態更改css類名)
                  How to remove default color in input type?(如何刪除輸入類型中的默認顏色?)
                  How to add click event to dynamically added html element in typescript(如何將點擊事件添加到打字稿中動態添加的html元素)
                  XPath one of multiple attribute values with condition(XPath 具有條件的多個屬性值之一)

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

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

                          • 主站蜘蛛池模板: 单螺旋速冻机-双螺旋-流态化-隧道式-食品速冻机厂家-广州冰泉制冷 | 电镀整流器_微弧氧化电源_高频电解电源_微弧氧化设备厂家_深圳开瑞节能 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司 | 防爆电机生产厂家,YBK3电动机,YBX3系列防爆电机,YBX4节防爆电机--河南省南洋防爆电机有限公司 | 医学动画公司-制作3d医学动画视频-医疗医学演示动画制作-医学三维动画制作公司 | 盐水蒸发器,水洗盐设备,冷凝结晶切片机,转鼓切片机,絮凝剂加药系统-无锡瑞司恩机械有限公司 | 耐酸碱泵-自吸耐酸碱泵型号「品牌厂家」立式耐酸碱泵价格-昆山国宝过滤机有限公司首页 | 北京西风东韵品牌与包装设计公司,创造视觉销售力! | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 玉米深加工设备-玉米深加工机械-新型玉米工机械生产厂家-河南粮院机械制造有限公司 | 偏心半球阀-电动偏心半球阀-调流调压阀-旋球阀-上欧阀门有限公司 | 【北京写字楼出租_写字楼租赁_办公室出租网/出售】-远行地产官网 | 小程序开发公司-小程序制作-微信小程序开发-小程序定制-咏熠软件 | 东莞工作服_东莞工作服定制_工衣订做_东莞厂服 | 安平县鑫川金属丝网制品有限公司,防风抑尘网,单峰防风抑尘,不锈钢防风抑尘网,铝板防风抑尘网,镀铝锌防风抑尘网 | 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 | 绿叶|绿叶投资|健康产业_绿叶投资集团有限公司 | 体感VRAR全息沉浸式3D投影多媒体展厅展会游戏互动-万展互动 | 深圳市宏康仪器科技有限公司-模拟高空低压试验箱-高温防爆试验箱-温控短路试验箱【官网】 | 青岛球场围网,青岛车间隔离网,青岛机器人围栏,青岛水源地围网,青岛围网,青岛隔离栅-青岛晟腾金属制品有限公司 | 不锈钢钢格栅板_热浸锌钢格板_镀锌钢格栅板_钢格栅盖板-格美瑞 | 钛板_钛管_钛棒_钛盘管-无锡市盛钛科技有限公司 | 钢木实验台-全钢实验台-化验室通风柜-实验室装修厂家-杭州博扬实验设备 | 电销卡_北京电销卡_包月电话卡-豪付网络 | 电子厂招聘_工厂招聘_普工招聘_小时工招聘信息平台-众立方招工网 | 长城人品牌官网 | 行业分析:提及郑州火车站附近真有 特殊按摩 ?2025实地踩坑指南 新手如何避坑不踩雷 | 色谱柱-淋洗液罐-巴罗克试剂槽-巴氏吸管-5ml样品瓶-SBS液氮冻存管-上海希言科学仪器有限公司 | 高铝矾土熟料_细粉_骨料_消失模_铸造用铝矾土_铝酸钙粉—嵩峰厂家 | 股票入门基础知识_股票知识_股票投资大师_格雷厄姆网 | RV减速机-蜗轮蜗杆减速机-洗车机减速机-减速机厂家-艾思捷 | 西门子气候补偿器,锅炉气候补偿器-陕西沃信机电工程有限公司 | 阿里巴巴诚信通温州、台州、宁波、嘉兴授权渠道商-浙江联欣科技提供阿里会员办理 | 首页|专注深圳注册公司,代理记账报税,注册商标代理,工商变更,企业400电话等企业一站式服务-慧用心 | 跨境物流_美国卡派_中大件运输_尾程派送_海外仓一件代发 - 广州环至美供应链平台 | 窖井盖锯圆机_锯圆机金刚石锯片-无锡茂达金刚石有限公司 | 南京和瑞包装有限公司| 伶俐嫂培训学校_月嫂培训班在哪里报名学费是多少_月嫂免费政府培训中心推荐 | 圣才学习网-考研考证学习平台,提供万种考研考证电子书、题库、视频课程等考试资料 | 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格|