Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: HTML
Expertise: Beginner
Jan 28, 2009



Application Security Testing: An Integral Part of DevOps

Adding Custom Attributes to HTML Elements

A custom attribute is any user-defined attribute, just like other primitive HTML element attributes. You can add custom attributes to any HTML element. For example, suppose you wanted to add the displayName attribute to the following HTML text box:

    <input type="text" id="txtBox" />
There are two ways to do this:
  1. You can add displayName when you write the HTML element tag in the web page:
         <input type="text" id="txtBox" displayName="displayNAME1" />
  2. You can use the DOM:
         document.all.txtBox.displayName = "displayNAME1";
As you can see, you access custom attributes the same way you'd access any built-in attributes. For example:

Deepak Choudhari
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date