how to add predefined attributes in html5

Description:
HTML5 is the latest and most enhanced version of HTML. Technically, HTML is not a programming language, but rather a markup language.

HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web.

Here i will explain how to add pre-defined attribute in HTML5. HTML5 allow to user defined attribute in any html element like the following below:

<div id="divTest" myattrname="my value"></div>
<input type="text" attrname="attrvalue" />

In above example "myattrname" is an your predefined attribute name and you can set its value as you like. Also you can get predefined attribute value by element id or class.

For example:

<script type="text/javascript">
        $("#divTest").attr("myattrname");
</script>

No comments:

Post a Comment