One interesting feature I have on my website is an HTML div that functions as a star rating system.
Currently, I am experimenting with some JavaScript code to test its functionality. My goal is for the console to log 'hello' whenever I click on one of the stars.
<div class=rating>
<div class="ratings_stars" data-rating="1"></div>
<div class="ratings_stars" data-rating="2"></div>
<div class="ratings_stars" data-rating="3"></div>
<div class="ratings_stars" data-rating="4"></div>
<div class="ratings_stars" data-rating="5"></div>
</div>
$('.ratings_stars').on('click', function() {
console.log('Hello');
});
The JavaScript code is stored in a separate file which I have successfully linked to.