HTML5 stipulates that it can add non-standard attributes to the element, but to add prefix Data-, the purpose is to provide the element with information that is not related to rendering, or provides semantic information. These attributes can be added and named arbitrarily. As long as the Data-starts with the beginning of the Data-, you can access the values of the custom attribute through the dataSet attribute of the element.
<div ID = BOX Data-Name = 'Ghostwu' Data-Age = '22 ', Data-sex =' Man '> Ghostwu Tell You How to Learn HTML5 </div> <script> Var Obox = DOCUMENT.QURY Selector (# Box); console.log (OBOX.DataSet); var myName = OBOX.DATASEASET.NAME; var my MyAge = ingataSet.age; var mysex = ingatasex; if (OBOX.DataSet .name) {console. LOG (OBOX.DataSet.name);} </script> SummarizeThe above is the use of HTML5 custom attribute prefix Data and DataSet (new features of HTML5), which is introduced by Xiaobian. I hope it will be helpful to everyone. If you have any questions, please leave me a message, Xiaobian will reply to everyone in time of. Thank you very much for your support for the VEVB Wulin website!