找到你要的答案

Q:How to get value in Star rating, jQuery

Q:如何在评级中获得价值,jQuery

I am using the star rating from this site : link But I can't seem to figure out how to get the rating from my radio buttons. I just need to display it in the console.log, the rest I can manage.

When the third is selected it looks like this:

If any more information is required, please ask, new to this.

I am using the star rating from this site : link But I can't seem to figure out how to get the rating from my radio buttons. I just need to display it in the console.log, the rest I can manage.

当第三被选中,它看起来像这样:

如果需要更多的信息,请询问,新的。

answer1: 回答1:

Get number of stars with the selected class .star-rating-on:

var rating = $('.star-rating-control .star-rating-on').length;

If there are more than one set of rating controls, please use a different parent selector, like article or .post:

$('article').each(function() {
    var rating = $(this).find('.star-rating-control .star-rating-on').length;
    // Do something...
}

获取选定类别的恒星数:

var rating = $('.star-rating-control .star-rating-on').length;

如果有一组以上的评级控件,请使用不同的父选择器,如文章或帖子:

$('article').each(function() {
    var rating = $(this).find('.star-rating-control .star-rating-on').length;
    // Do something...
}
answer2: 回答2:

Please use following code to get the value of rating:

$('.auto-submit-star').rating({ callback: function(value, link){ alert(value); } });

Replace .auto-submit-star with your selector

请使用以下代码获得评级值:

$('.auto-submit-star').rating({ callback: function(value, link){ alert(value); } });

更换自动提交星与您的选择器

answer3: 回答3:

The simple way is

  1. Create a form. Form will help you to post rating data.
  2. inside form create radio buttons as per your need.
  3. Call javascript api to change radio buttons into stars.
  4. There are 2 ways to get data from rating a. submit a form and get result using $_POST or $_GET or $_REQUEST b. Use ajax

Note:- This plugin return selected radio button value.

简单的方法是

  1. Create a form. Form will help you to post rating data.
  2. inside form create radio buttons as per your need.
  3. Call javascript api to change radio buttons into stars.
  4. There are 2 ways to get data from rating a. submit a form and get result using $_POST or $_GET or $_REQUEST b. Use ajax

注意:此插件返回单选按钮值。

javascript  jquery  html  jquery-plugins  rating-system