开发者社区> 问答> 正文

jquery获取动态添加的表单元素

有一个页面,在页面载入的时候,使用ajax动态创建一个input元素,如下

success: function(file, response){
      response = JSON.parse(response);
      img_path = response.file_path;
      html = '<input type="hidden" class="goods_other_img" name="goods_other_img[]" value="'+img_path+'" />';
      $('#goods_other_img').append(html);
    }

jquery选择器不能选择动态添加的元素,请问该如何获得新添加的这个input?

展开
收起
小旋风柴进 2016-05-27 11:21:19 2831 0
2 条回答
写回答
取消 提交回答
  • 专注物联网

    var input = $('#goods_other_img').children('.goods_other_img');

    2019-07-17 19:17:29
    赞同 展开评论 打赏
  • var input = $('#goods_other_img').children('.goods_other_img');

    2019-07-17 19:17:29
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
Javascript中的对象 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载