Jump to content

Element properties just for Javascript reference?


davej
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...