davej Posted September 12, 2013 Share Posted September 12, 2013 What if you wanted to assign a property to an input just to identify some sort of desired reference for Javascript? What would the best practice be in that situation? Is there an appropriate do-nothing property for that purpose? For example a particular radio button is associated with the visibility of particular fields in a different part of the page. When Javascript scans the radio button it can also read the cross-reference property to get the class of the text fields that are to be toggled. I could use class, but that might create confusion since it would not be intended for styling. I could use undefined/custom attributes but that might also cause confusion. I believe browsers are supposed to ignore any attribute they don't understand, but is that considered bad practice? Input properties: http://www.w3schools.com/tags/tag_input.asp Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2013 Share Posted September 12, 2013 You could use class, sometimes I use rel. You can also create your own prefixed with data-, e.g.: <input data-test="value" ... Link to comment Share on other sites More sharing options...
davej Posted September 12, 2013 Author Share Posted September 12, 2013 Is "data-" some sort of convention? Link to comment Share on other sites More sharing options...
Ingolme Posted September 12, 2013 Share Posted September 12, 2013 It allows custom attributes pass the validator in HTML 5. It's part of the specification. Link to comment Share on other sites More sharing options...
davej Posted September 12, 2013 Author Share Posted September 12, 2013 Oh. http://html5doctor.com/html5-custom-data-attributes/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now