复制代码 代码如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js函数中获取事件源</title>
<script type="text/javascript" language="javascript">
function chang() {
var evt = event || window.event;
alert(evt.srcElement.id);
}
</script>
</head>
<div>
<input type="text" onclick="chang();" id="input_a" />
<input type="text" onclick="chang();" id="input_b" />
</div>
<body>
</body>
</html>
时间: 2024-12-31 00:52:37