我在jQuery中有一个函数,它不能按预期工作

时间:2010-08-12 11:09:32

标签: jquery

function hideShowTextBox(tabName, index, tabContainer) {
  var tabIndex = index + 1;
  var dropDownId = tabContainer + '_' + tabName + '_IncomeDetails' + tabIndex + '_dpEmploymentStatus';

  //this line gives a blank value..What may be the problem???
  alert($(dropDownId + ' option:selected').text()); 
}

1 个答案:

答案 0 :(得分:2)

ID选择器必须以#字符开头,例如#foo。尝试:

var dropDownId = '#' + tabContainer + '_' + tabName + '_IncomeDetails' + tabIndex + '_dpEmploymentStatus';