获得表格字段的价值

时间:2016-09-15 20:25:27

标签: javascript forms

我在页面上动态创建了几个字段。我使用以下函数将该行的ID字段与正确的" ntheme"该行的字段。

$(document).on('change', 'select', function() {
  var checkbox = $(this),
    otherInput = $('nrowid' + this.id.replace('ntheme', ''));
    console.log(otherInput);
   console.log($(this).val());
 for(var i=0;i<rows1;i++){
  if($(this).val()==themes[i].Themes){
//set value of otherinput to themes[i].ID

  }
 }

  console.log(otherInput.val());
});

有没有办法可以设置otherInput字段的值,然后使用console.log返回该值?

1 个答案:

答案 0 :(得分:0)

//获取 var otherInput2 = $('#nrowid')。val();

//设置 var otherInput2 = $('#nrowid')。val('your value');

的console.log(otherInput2);

相关问题