숫자를 별 등급(평점)으로 변환하는 jQuery

Last Updated: 2020년 11월 15일 | | 2개 댓글

숫자를 별 평점으로 변환하는 jQuery 스크립트 예제입니다.

$.fn.generateStars = function() {
return this.each(function(i,e){$(e).html($('<span/>').width($(e).text()*16));});
};

// 숫자 평점을 별로 변환하도록 호출하는 함수
$('.star-prototype').generateStars();
//Source: http://htmlexplorer.com/2014/05/display-star-ratings-using-jquery-and.html

jQuery for converting a number to star rating

참고로 이 글에서는 워드프레스에서 사용자 정의 필드(Custom Field)로 숫자를 받아서 별 등급(평점)으로 변환하는 PHP 코드가 소개되어 있습니다.


2 개 댓글

Leave a Comment