sou*_*w93 108 javascript jquery
.click
如果textarea已经聚焦,我如何检测事件何时触发?
我有这个javascript:
$(".status").on("click","textarea",function(){
if ($(this) == "focused") {
// fire this step
}else{
$(this).focus();
// fire this step
}
Run Code Online (Sandbox Code Playgroud)
Pri*_*orn 284
使用纯javascript:
this === document.activeElement // where 'this' is a dom object
Run Code Online (Sandbox Code Playgroud)
或者使用jquery的:focus
伪选择器.
$(this).is(':focus');
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
155515 次 |
最近记录: |