I just need a function to return true or false if a textbox is selected. I am pretty new to JavaScript so I don’t even know if this is possible. Also preferably in JavaScript > jQuery
I have tried onclick but it didn’t work. I have also tried many other options shown in other answers but nothing seems to work.
2
Answers
As already mentioned use
.addEventListener('focus', () => {})
it should workYou can check if the input element matches the
:focus
pseudo-class.