You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<a href="#" aria-label="Like this post" class="irecommendthis" data-post_id="12217" title="Like" data-like="Like" data-unlike="Unlike"><span>10</span><span>Like</span></a>
The data-post_id and data-like attributes in anchor () tag are custom data attributes used to store additional information within HTML elements. These attributes do not have any default functionality in HTML but will be used in JavaScript to store and manipulate data.
data-post_id: This attribute holds the unique identifier for the post being liked. In this example, the value is "12217". This value is used by JavaScript to identify which post the like action should be applied to. For example, when a user clicks the “like” button, the JavaScript can read this attribute and send the post ID to the server to register the like.
data-like and data-unlike: These attributes hold text values that are likely used for toggling the like state. The data-like attribute has the value "Like", which might be displayed when the post is not liked yet. The data-unlike attribute holds the value "Unlike", which might be displayed when the post is already liked. JavaScript can use these attributes to change the button’s appearance and text based on the like state.
Use something like this
<a href="#" aria-label="Like this post" class="irecommendthis" data-post_id="12217" title="Like" data-like="Like" data-unlike="Unlike"><span>10</span><span>Like</span></a>
The data-post_id and data-like attributes in anchor () tag are custom data attributes used to store additional information within HTML elements. These attributes do not have any default functionality in HTML but will be used in JavaScript to store and manipulate data.
About HTML data attributes:
https://blog.openreplay.com/custom-data-attributes-in-html5/?ref=dailydev
The text was updated successfully, but these errors were encountered: