里面这是我的脚本:获取变量和其他放输入
jQuery('#postcustomstuff tbody > tr:nth-child(3)').click(function() {
// Get IDs
var poleRatingsAverage = jQuery('#postcustomstuff tbody > tr:nth-child(2)').attr('id');
var poleRatingsUsers = jQuery('#postcustomstuff tbody > tr:nth-child(4)').attr('id');
var poleRatingsScore = jQuery('#postcustomstuff tbody > tr:nth-child(3)').attr('id');
var ratings_average = jQuery(poleRatingsUsersTextAreaID).val();
var ratings_users = jQuery(poleRatingsUsersTextAreaID).val();
var ratings_score = parseInt(ratings_average) * parseInt(ratings_users);
})
我有一个问题,我的jQuery脚本。我必须从变量中获得ID:poleRatingsAverage
,poleRatingsUsers
和poleRatingsScore
。我试过这个:
alert(poleRatingsAverage); <---- This return good but in next part I must add VALUE to this:
// Values Start
var ratings_average = jQuery(poleRatingsAverage+'-value').val();
var ratings_users = jQuery(poleRatingsUsers+'-value').val();
var ratings_score = parseInt(ratings_average) * parseInt(ratings_users);
jQuery(poleRatingsScore+'-value').val(ratings_score); // Math
// Values End
我在做什么错在我的脚本?
就像在所有查询选择器前放置'#'一样简单吗?只需把'poleRatingsAverage =“#”+ poleRatingsAverage;'放在开头。 – Archer