The JavaScript function gets a small example of the event source

  • 2020-03-30 02:57:18
  • OfStack

 
<!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 Gets the event source in the </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> 

Related articles: