jquery中在子窗口中获取父窗口的Input文本值

1.父页面

<input type="hidden" name="billNo" id="billNo" value="${entity.billNo}" />

2.子页面中

//一键绑定
  $('#batch_bind').click(function(){
      console.log($("#billNo",window.parent.document).val());
      var arrItemId = [];
      $("tbody :checkbox:checked", $table).each(function(i) {
            var item = _table.row($(this).closest('tr')).data();
            var params = {
              'id' : item.id
            };
            arrItemId.push(params);
          });
      if (JSON.stringify(arrItemId) == "[]") {
        alert2("请勾选一行数据!");
        return;
      }
      var ids=[];
      for(var i=0;i<arrItemId.length;i++){
          ids.push(arrItemId[i].id);
      }
      console.log(ids.toString());
      if($("#billNo",window.parent.document).val()==null){
          alert2("请先选择你要绑定的开支编号");
      }
      $.ajax({
            type : 'POST',
            url : '/expenditure/bind',
            cache : false,     // 禁用缓存
            data : {
                ids: ids.toString(),
               billNo :$("#billNo",window.parent.document).val()
            }, 
            dataType : 'json',
            success : function(result) {
                console.log(result);
               refresh();
              window.parent.refresh();
            },
            error:function(){
                console.log('error')
            }
        });
      });
 

猜你喜欢

转载自blog.csdn.net/xiao297328/article/details/82349320