我有以下脚本。当我最初编写它时,它运行良好。然后我加载了页面,它已经损坏并且永久返回NaN
。我能够在控制台中成功运行它,但由于某种原因它无法在站点上正常运行。它在 Rails 应用程序内部运行。
$(document).ready(function(){
$('select').click(function(){
var often = parseInt($('#biohaz_frequency_often').val());
var time = parseInt($('#biohaz_frequency_time').val());
var timeoften = often * time
if(timeoften == 0){
var freq = 0;
}
else if(timeoften <= 2){
var freq = 1;
}
else if(timeoften <= 4){
var freq = 3;
}
else if(timeoften <= 9){
var freq = 6;
}
else if(timeoften > 9){
var freq = 10;
}
var sever = parseInt($('#biohaz_risk_severity').val());
var master = parseInt($('#biohaz_risk_mastery').val());
$('#risk_frequency').html(freq);
$('#risk_total').html(freq * sever * master);
})
})