variables in callbacks

variables in callbacks

<html>
<head>
   <title>untitled</title>
   <!-- Date: 2009-10-28 -->
   <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        jQuery.noConflict();
       jQuery(document).ready(function()
       {
         createElements();
       });
   
      function createElements(){
         var tester = new Object();
         tester.t1 = "id1";
         tester.t2 = "id2";
         tester.t3 = "id3";
         tester.t4 = "id4";
         for(test in tester){
            var newelem = jQuery("<div>").attr("id",test).append(test);
            newelem.click(function () {
               alert("my id is: "+this.id);
               alert("registered variable: "+test);
            });
            jQuery("#test").append(newelem);
         }
      }
   
   </script>
</head>

<body>
<div id="test"></div>
</body>
</html>


Hello! Does anyone know how to do this without using "this" in the click callback. I know it registers a anonymous function with a reference to "test" wich then holds the last iterated element.

What would be the best way to do this?

Kind Regards!