简体   繁体   English

如何检索在jQuery星级中单击的星级的值

[英]how to retrieve the value of the star clicked in a jquery star rating

I am using a jquery star rating plugin.the link is [here] ( http://irfandurmus.com/projects/jquery-star-rating-plugin/ ). 我使用的是jquery星级评分插件。链接为[here]( http://irfandurmus.com/projects/jquery-star-rating-plugin/ )。 here's the image 这是图像

I have a table in which one column have a star rating to rate an item. 我有一张桌子,其中一栏有星级来评价一个项目。 I am looping the star rating to rate the item present in all rows.I need to get the value of star clicked in each row . 我正在对星级进行循环评价,以对所有行中存在的项目进行评级。我需要获取每一行中单击的星级的值。 However i couldn,t get the value of star clicked in each row. 但是我无法获得每一行点击的星号的值。 please help me with this. 请帮我解决一下这个。

You can use something like this: 您可以使用如下形式:

$('td .rating-div').each(function(){
   console.log($('.stars').find('a.fullStar.star').length);
});

You can do it with Javascript: 您可以使用Javascript完成:

jQuery('.star').on("click", function(){
  var rating = jQuery(this).attr('title');
});

Another way 其他方式

$('.rating-div').each( function() { 
    console.log( $(this).find('> .stars > .fullStar:last').attr("title")  ) 
} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM