Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the attributes of the like link #39

Open
hchouhan opened this issue Jul 20, 2024 · 0 comments
Open

Change the attributes of the like link #39

hchouhan opened this issue Jul 20, 2024 · 0 comments
Milestone

Comments

@hchouhan
Copy link
Member

hchouhan commented Jul 20, 2024

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.

  1. 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.
  2. 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.

About HTML data attributes:
https://blog.openreplay.com/custom-data-attributes-in-html5/?ref=dailydev

@hchouhan hchouhan added this to the 3.10.0 milestone Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant