HTML5 Data Attributes: data-*

Data attribute provides to define custom data attributes in HTML5. Data attribute format is “data-*” that “*” means desired custom attribute name. This useful data attribute has very simple usage.

Example: If you need row index number of a table.

Foo Check index
Bar Check index

jQuery(document).ready(function() {
$(".to-see").click(function(e) {
var index = $(this).data("row-index");
if (index < 25) {

It would be before clicking check index:

After clicking check index, it would look like:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s