doumen5895 2014-09-01 13:10
浏览 131
已采纳

按钮加载ajax时触发事件

I have a form to send someone a message, and I need to create a list of people to the user pick one and send him the message.

So I've created a search field that shows that list:

$('#name').keyup(function(){
    var name, goURL;
    goURL = site_url + 'events/search';
    name = $(this).val();
    $.post(goURL, {name : name}).done(function(data){
        $('.results').html(data);
    });
});

Then I get a list from users, that comes from a method of codeigniter and in each user I have a button that allows me to pick this user.

    $('.results').on('on', '.select-btn', function(){
        alert('Test');
    });

But when I click, nothing happens. How to proceed? Thank you and sorry for my bad English.

  • 写回答

1条回答 默认 最新

  • doudihuang7642 2014-09-01 13:11
    关注

    you need to use click event as event while binding using on:

    $('.results').on('click', '.select-btn', function(){
        alert('Test');
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 综合布线实例设计,就好看好看不恐怖可好滤镜好聚
  • ¥15 使用moviepy库视频合并时出错
  • ¥30 FLUENT液固传质UDF
  • ¥15 怎么看梯度直方图以,怎么判断梯度消失/爆炸,怎么解决
  • ¥15 aspnetdll文件访问拒绝
  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关