Home > Article > Web Front-end > Shield the javascript code of a certain function of js in textarea_form effects
There is a textarea. I want to block a certain function when the focus is in this textarea.
It means to invalidate this function and make it valid again after removing the focus. How to achieve this? ? ?
1st floor
In your function, use document.activeElement to get the control that the current webpage is focused on. If it is judged to be this textarea, it will jump out and not execute this function.
2nd floor
The correct answer is upstairs. meizz learning
3rd floor
to meizz (Mei Huaxue)
I use
document.activeElement.tagName.toLowerCase()!='textarea'
to judge the textarea control, but the page There are multiple textareas on
I only want to block this function in one of the textareas. How should I do it? ? ?
What’s even more troublesome is that there is another hidden textarea. Except for the readonly attribute, the other attributes are exactly the same as this textarea. How to implement it? ? ?
Floor 4
Use onfocus, onblur events as function switches