There is a textarea, I want to block a function when the focus is in this textarea,
It is to invalidate this function, and then remove the focus and make it effective again. How to implement it? ? ?
1st floor
In your function, get the control that focuses on the current web page, and judge this if this is textarea, then the function will not be executed
2nd floor
The correct answer is upstairs, learn from meizz
3rd floor
to meizz(Plum Blossom Snow)
I'm using
()!='textarea'
To judge the textarea control, but there are multiple textareas on the page.
I just want to block this function in one of the textareas. How to do it? ? ?
What's even more troublesome is that there is another hidden textarea. Except for the property readonly, other attributes are exactly the same as this textarea. How to implement it? ? ?
4th floor
Use onfocus and onblur events as function switches
<body>
<script language="JavaScript">
function disablefun()
{
= null;
}
function enablefun()
{
= function()
{
+= "i'm active<br>";
};
}
function myfun()
{
+= "i'm active<br>";
}
</script>
<form method="get" name=search id=search target="_blank">
Myfun function is triggered every time you type something<br>
<textarea name="txa" rows="5" cols="20" onkeydown="if(myfun)myfun()"></textarea>
<hr>
<br>
Each key press does not trigger the myfun function (it fails when focusing, and is effective when out of focus)<br>
<textarea name="txa" rows="5" cols="20" onfocus="disablefun()" onblur="enablefun()" onkeydown="if(myfun)myfun()"></textarea>
</form>
<div id=showid>
</div>
</body>
It is to invalidate this function, and then remove the focus and make it effective again. How to implement it? ? ?
1st floor
In your function, get the control that focuses on the current web page, and judge this if this is textarea, then the function will not be executed
2nd floor
The correct answer is upstairs, learn from meizz
3rd floor
to meizz(Plum Blossom Snow)
I'm using
()!='textarea'
To judge the textarea control, but there are multiple textareas on the page.
I just want to block this function in one of the textareas. How to do it? ? ?
What's even more troublesome is that there is another hidden textarea. Except for the property readonly, other attributes are exactly the same as this textarea. How to implement it? ? ?
4th floor
Use onfocus and onblur events as function switches
<body>
<script language="JavaScript">
function disablefun()
{
= null;
}
function enablefun()
{
= function()
{
+= "i'm active<br>";
};
}
function myfun()
{
+= "i'm active<br>";
}
</script>
<form method="get" name=search id=search target="_blank">
Myfun function is triggered every time you type something<br>
<textarea name="txa" rows="5" cols="20" onkeydown="if(myfun)myfun()"></textarea>
<hr>
<br>
Each key press does not trigger the myfun function (it fails when focusing, and is effective when out of focus)<br>
<textarea name="txa" rows="5" cols="20" onfocus="disablefun()" onblur="enablefun()" onkeydown="if(myfun)myfun()"></textarea>
</form>
<div id=showid>
</div>
</body>