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)