裏面這是我的腳本:獲取變量和其他放輸入
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