如何得知点击在指定区域外?

akira1986 2008-01-28 04:22:28
有个div,进行点击,如何知道是点在div里面了还是点在外面了,请高手指点。
...全文
47 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
akira1986 2008-01-29
  • 打赏
  • 举报
回复
谢谢,问题已经解决,你这样的写法是不错,可是我如果在div里再放上button的话就会有问题了(可能不起作用或会提示out了)。。。
剑心永远OK 2008-01-29
  • 打赏
  • 举报
回复
纯粹路过
yixianggao 2008-01-28
  • 打赏
  • 举报
回复
抠门,哈

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="yixianggao@126.com" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<style type="text/css">
html, body
{
margin: 0px 0px 0px 0px;
height: 100%;
}
</style>
</head>
<body onclick="alert('out');">
<div style="width: 100px; height: 100px; background-color: yellow;" onclick="alert('in');event.cancelBubble=true;">

</div>
</body>
</html>

87,910

社区成员

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

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