While I was going through the HTML of some pages, I noticed that some of them use this attribute "data-reactid" like :
<a data-reactid="......" ></a>
What is that attribute and what is its function ?
This question is related to
javascript
html
reactjs
Custom Data attribute in HTML5
Would like to quote Ian's comment in my answer:
It's just an attribute (a valid one) on the element that you can use to store data/info about it.
This code then retrieves it later in the event handler, and uses it to find the target output element. It effectively stores the class of the div where its text should be outputted.
reactid
is just a suffix, you can have any name here eg: data-Ayman
.
If you want to find the difference check the fiddles in this SO answer and comment.
That's the HTML data attribute. See this for more detail: http://html5doctor.com/html5-custom-data-attributes/
Basically it's just a container of your custom data while still making the HTML valid.
It's data-
plus some unique identifier.
It's a custom html attribute but probably in this case is used by the Facebook React JS Library.
Take a look: http://facebook.github.io/react/
data attributes are commonly used for a variety of interactions. Typically via javascript. They do not affect anything regarding site behavior and stand as a convenient method to pass data for whatever purpose needed. Here is an article that may clear things up:
http://ejohn.org/blog/html-5-data-attributes/
You can create a data attribute by prefixing data-
to any standard attribute safe string (alphanumeric with no spaces or special characters). For example, data-id
or in this case data-reactid
Source: Stackoverflow.com