weixin_33705053 2018-09-05 07:32 采纳率: 0%
浏览 9

注意变化jQuery

How can i watch for html changes. I have one button witch will add more html, when im saving the data with ajax, ajax won't watch/read the added html.

As it is now when i click save the new html is not processed.

$("#more_column").click(function(e){
     $(col).after('<div class"class"></div>.......')
});

I append this html, this html appended won't be processed with the ajax later. How to make the ajax or jquery watch for html changes? Any idea ?

I have seen also alternatives with Vue.js if there are any examples please share.

  • 写回答

1条回答 默认 最新

  • 游.程 2018-09-05 08:25
    关注

    You can do this. you have to add your ajax success callback.

    $.ajax({
        method: "POST",
        url: "data.php",
        data: { key: "id", value: "1234" }
    }).done(( data ) => {
        $(col).after(`<div class"class">${data}</div>`)
    });
    

    reference: http://api.jquery.com/jquery.ajax/

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料