获取动态创建的输入文本的值

时间:2018-03-02 15:53:40

标签: jquery

我有输入字段,第一个是手动添加而其他人是通过单击按钮创建的,我向所有人添加了相同的类,我想尝试获取值但我无法获得值动态创建的

<div class="col-md-4" >
         <div class="dev_spec"><input type="text" class="form-control list-title-input" ></div>
         <div class="dev_spec"><input type="text" class="form-control list-title-input" ></div>
      </div>
<div class="col-md-4" style="padding-left: 0">
          <div title="add specification" class="btn btn-success add_define_spec float-left"  data-id="1" style="width:40px; height:35px; margin-right: 10px;">
              <span ><i class="glyphicon glyphicon-plus" ></i></span>
          </div>
          <div title="upload file" class="btn btn-default upload_define_spec float-left fileUpload" style="width:40px; height:35px;">
              <span ><i class="glyphicon glyphicon-upload" ></i></span>
               <input type='file' class='upload specPhoto'>&nbsp;&nbsp;
          </div>
          <div class='spec-image float-left'><img src="<?=$img.'usericon.png'?>" alt="specimge"></div>
      </div>

$(document).on('click','.add_define_spec',function(){

       var define_spec_div = $(
         '<div class="define_spec">'+
           '<div class="col-md-12 invisible-divider-20"></div>'+
        '<div class="col-md-3" ></div>'+
        '<div class="col-md-4 " >'+
          '<div class="dev_spec"><input type="text" class="form-control list-title-input"></div>'+
        '</div>'+
        '<div class="col-md-4" style="padding-left: 0">'+
            '<div title="add specification" class="btn btn-success add_define_spec float-left"  data-id="" style="width:40px; height:35px; margin-right: 10px;">'+
                '<span ><i class="glyphicon glyphicon-plus" ></i></span>'+
            '</div>'+
            '<div title="upload file" class="btn btn-default upload_define_spec float-left fileUpload" style="width:40px; height:35px; ">'+
              '<span ><i class="glyphicon glyphicon-upload" ></i></span>'+
              "<input type='file' class='upload specPhoto'>&nbsp;&nbsp;"+
            '</div>'+
            "<div class='spec-image float-left'><img src='"+\$imgUrl+'usericon.png'+"' alt='specimge'></div>"+
            '<div title="remove specification" class="btn btn-danger remove_define_spec float-left" data-id="2" style="width:40px; height:35px; margin-right: 10px; margin-left: 10px;">'+
              '<span ><i class="glyphicon glyphicon-minus" ></i></span>'+
            '</div>'+

        '</div>'+
       '</div>');
       $(".define_spec_container").append(define_spec_div);
  });

$('.dev_spec :input').on('focus', function(event) {      
        }).on('blur', function(event) { 
           //id = $(this).attr('data-id');
         val = $(this).val();
           console.log(val); return;

        });

请任何人可以帮助我这么多谢谢

0 个答案:

没有答案