timpone
timpone

Reputation: 19969

How to capture focus for either an input OR a textarea

I would like to detect when an input or textarea has recieved focus. For input I have:

$('body').on('focus','input', function(){

How would I add textarea to this? Tried

$('body').on('focus',['input','textarea'], function(){

but no dice

Upvotes: 1

Views: 38

Answers (1)

Josh Crozier
Josh Crozier

Reputation: 240908

It should be:

$('body').on('focus', 'input, textarea', function () { ... });

Upvotes: 1

Related Questions