TextBox的onblur事件中隐藏自己引发的问题

icyer 2003-04-07 02:49:42
在onblur事件中隐藏自己,如果是单击Button引起onblur的,就不会执行Button的onclick。模拟的代码如下:
<html>
<body>
<script language=javascript>
function test()
{
var txt = document.getElementById("txt1");
txt.style.display="none";
window.status = txt.value;
}
</script>
<textarea id="txt1" name="txt1" onblur="test()"></textarea>
<br>
<input type=button value="button" onclick="alert('click button');">
</body>
</html>

单击Button,能隐藏txt1,但是不会显示alert
...全文
23 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wsj 2003-04-07
  • 打赏
  • 举报
回复
txt.style.display="none";

==>

txt.style.visibility = "hidden"
qiudehuo 2003-04-07
  • 打赏
  • 举报
回复
<html>
<body>
<script language=javascript>
function test()
{
var txt = document.getElementById("txt1");
txt.style.display="none";
window.status = txt.value;
window.event.cancelBubble = true;
window.event.returnValue = false;
}
</script>
<textarea id="txt1" name="txt1" onblur="test()"></textarea>
<br>
<input type=button value="button" onclick="alert('click button');">
</body>
</html>
fason 2003-04-07
  • 打赏
  • 举报
回复
<input type=button value="button" onmousedown="alert(txt1.value);">
心云意水 2003-04-07
  • 打赏
  • 举报
回复
<html>
<body>
<script language=javascript>
function test()
{
var txt = document.getElementById("txt1");
txt.style.display="none";
window.status = txt.value;
}
</script>
<textarea id="txt1" name="txt1" onblur="test()"></textarea>
<br>
<input type=button value="button" onmousedown="alert('click button');">
</body>
</html>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧