DEV Community

Vinkal Prajapati
Vinkal Prajapati

Posted on

Rate Now

HTML:

Blog post content with a title, description, and a star rating system.
Two paragraphs for displaying the rating and the "Thank You" message (initially hidden).

CSS (styles.css):

Basic styling for the blog post and star rating elements.
A "hidden" class to initially hide the "Thank You" message.
Styling for the fading-in animation.

JavaScript (script.js):

Keeps track of the user's rating (userRating variable).
Functions:
ratePost(rating): Records the user's rating, updates the display, and triggers the "Thank You" message.
updateRatingDisplay(): Updates the displayed rating.
updateStars(): Updates the appearance of the stars based on the user's rating.
showThanksMessage(): Shows the "Thank You" message with a fading-in animation and hides it after a few seconds.
This code provides a user-friendly interface for rating blog posts, giving feedback to users, and enhancing the overall user experience.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay