在if条件为true的情况下,我尝试增加全局定义的变量maximumPurposeValue的值,但是它不起作用。每次返回1。我在做什么错?
var highestPurposeValue = 0;
$('#addJobPurposeButton').on('click', function(){
var value = $('#jobPurposeInputForm').val();
$('#jobPurposeList li').map(function () {
var item = $(this).find("input[name^='jobPurpose']").attr('name');
var itemNumber = item.match(/\d+/); // returns an array.
if (itemNumber[0] > highestPurposeValue) {
var num = parseInt(itemNumber[0]);
var plusOne = num+1;
highestPurposeValue = plusOne;
}
});