日期:2014-05-16 浏览次数:20346 次
<!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></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#txt1").click(function () {
$("#div1").show();
});
$(document).click(function (e) {
e = window.event;
var obj = $(e.srcElement
------解决方案--------------------
e.target);
if ($(obj).is("#txt1,#div1")) {
$("#div1").show();
} else {
$("#div1").hide();
}
});
});
</script>
</head>
<body>
<input type="text" id="txt1" />
<div id="div1" style="display: none">
div1
</div>
</body>
</html>