问题
Since I cannot search for this with meaningful results, I can't be sure that this is not a duplicate.
However, I am running a JSSOR Slider on my site and some of the elements have a u property for example:
<div u="slides" style="cursor: move;
position: absolute; left: 0px; top: 0px; width:
1300px; height: 500px; overflow: hidden;">
This "u=slides" is throwing up an error when I run it through a W3 Validator, however when I remove this property from the element, the slider no longer functions.
I am wondering the purpose of this property as I see no markup for it anywhere, and wondering if it can be substituted for anything in order to make the site pass markup validation.
Thanks in advance.
回答1:
Custom attributes (in HTML5) can be assigned to elements using the data-* prefix:
<elem data-u="slides"></elem>
The problem here, however, is that whoever developed this JSSOR Slider plugin has decided not to use valid HTML5 markup. Unless the plugin's JavaScript code is modified to look for a data-* attribute rather than an invalid attribute named "u", you will not be able to modify this attribute without breaking the way your site functions.
Update: Digging deeper I've discovered that this was already raised as an issue on JSSOR's GitHub repository back in January: https://github.com/jssor/jquery-slider/issues/4. They've rectified this by allowing you to use a valid data-u attribute instead of u.
The Solution
Provided your JSSOR plugin code is up to date. You can simply modify your HTML to:
<div data-u="slides" style="...">
来源:https://stackoverflow.com/questions/25382581/u-property-within-an-element