Let me put the code first then we will do the post mortem
Try for yourself:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.js"></script>
</head>
<body>
<input type="button" value="Trigger Alert" id="btn_trig">
<script type="text/javascript">
/* $('#btn_trig') gives reference to the html element whose id is passed,
* similiar to getElementById() function. On that reference a callback function is defined
* syntax of callback functions is like this event( function(){ //thing you want to do on event happening}). Callback functions are called when event happens.
*
*/
$('#btn_trig').click(function(){
alert("Hello World!");
}
);
</script>
</body>
</html>
Try for yourself:
No comments:
Post a Comment