方法上的jQuery数据

方法上的jQuery数据,jquery,ajax,click,Jquery,Ajax,Click,我使用的是.on方法,因为我加载的html按钮是基于AJAX的。为什么我得不到数据?它返回undefined var $content_details = $('.content_details'), thumb = $('button.thumbs'); $content_details.on('click', thumb, function(){ alert( $(this).data('video') ); }); <button class="thumbs"

我使用的是.on方法,因为我加载的html按钮是基于AJAX的。为什么我得不到数据?它返回undefined

var $content_details = $('.content_details'),
    thumb = $('button.thumbs');

$content_details.on('click', thumb, function(){

    alert( $(this).data('video') );
});

<button class="thumbs" data-video="1">Button</button>
var$content\u details=$('.content\u details'),
拇指=$('button.thumbs');
$content\u details.on('click',thumb,function()){
警报($(this.data('video'));
});
按钮
方法.on()的参数不正确。它应该是选择器,而不是jQuery对象

$content_details.on('click', 'button.thumbs', function(){
    alert( $(this).data('video') );
});

on()
的第二个参数必须是选择器(即字符串),而不是jQuery对象。我觉得自己很迟钝,谢谢!