How do I detect when .click
event triggers if textarea is already focused?
I have this jquery:
$(".status").on("click","textarea",function(){
if ($(this) == "focused") {
// fire this step
}else{
$(this).focus();
// fire this step
}
This question is related to
javascript
jquery
Did you try:
$(this).is(':focus');
Take a look at Using jQuery to test if an input has focus it features some more examples
Using jQuery's .is( ":focus" )
$(".status").on("click","textarea",function(){
if ($(this).is( ":focus" )) {
// fire this step
}else{
$(this).focus();
// fire this step
}
If you can use JQuery, then using the JQuery :focus selector will do the needful
$(this).is(':focus');
Source: Stackoverflow.com