HTML
<div id="div" tabindex="1">Div</div>
<object id="swf" tabindex="1"><!--Embedded with swfobject--></object>
JS
//This works, so it looks like focus should work an any element with tabindex set
$('#div').on('focus', function()
{
console.log('Div focus event');
});
//This works, so it looks like the browser and Flash support the events
$('#swf').onblur = function()
{
console.log('SWF onblur');
}
//This does not work
$('#swf').on('focus', function()
{
console.log('SWF focus event');
});
为什么onfocus
有效,但on('focus')
没有?除了转发事件之外,jQuery还在做什么吗?
答案 0 :(得分:2)
试试这个
$(body).on('focus', '#swf', function(){});
希望有所帮助