在默认状态下,通常只有表单元素才会支持focus和blur事件,对于其他的元素没有效果,但是只要将此元素设置一个tabindex属性就可以使用上述两个事件了,上面的效果就是根据此道理来实现的。
$('#emoji-' + comment_id).next('div').children('div').attr('tabindex', '-1');
$('#emoji-' + comment_id).next('div').children('div').focus();
如此即可获得焦点事件
![](https://img.haomeiwen.com/i11560533/fad0328f0b00bfa6.png)
网友评论