Пример:
В примере будет открыто диалоговое, содержащее данные.
"jQuery"
$("div").each(function(i) { $(this).bind('click', {index:i}, function(e){ alert('my index is ' + e.data.index); return false }); });
"HTML"
<div>Index 0</div> <div>Index 1</div>
"CSS"
div { margin:3px; width:100px; height:100px;
background:green;}
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="http://slyweb.ru/css/jqueryiframe.css"
rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div").each(function(i) {
$(this).bind('click', {index:i}, function(e){
alert('my index is ' + e.data.index);
return false
});
});
});
</script>
</head>
<body class="iframe">
<div>Index 0</div>
<div>Index 1</div>
</body>
</html>
<style>
div { margin:3px; width:100px; height:100px;
background:green;}
</style>