All pastes #158903 Raw Edit

Stuff

public text v1 · immutable
·published 2006-09-02 13:16 UTC
rendered paste body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
	<script type="text/javascript">
	
		function my_class()
		{
			this.bind_events = bind_events;
			this.method = function() { alert("the method"); }
		}
		
		function bind_events()
		{
			var divs = document.getElementsByTagName("div");
			var i, len = divs.length;
			for (i = 0; i < len; i++)
			{
				divs[i].obj = this;
				divs[i].onclick = click_div;
			}
		}
		
		function click_div()
		{
			this.obj.method();
		}
		
		window.onload = function()
		{
			var obj = new my_class();
			obj.bind_events();
		}
	
	</script>
	<style>
	
		div
		{
			margin:50px;
			width:150px;
			height:50px;
			background-color:#000000;
			cursor:pointer;
		}
	
	</style>
</head>

<body>

<div id="one">&nbsp;</div>
<div id="two">&nbsp;</div>
<div id="three">&nbsp;</div>
<div id="four">&nbsp;</div>

</body>
</html>