Hi, I'm stuck with some code.
I want to create some part of my html document by javascript. Every line contains some links, the links should trigger an action on that line. Here is some minimal sample code to reproduce the problem: -------8<---------------------------------------------------------------- <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> linecount = 1; function makeTestLines(parent) { linename = "Row" + linecount++; // insert a paragrah with 2 links parent.append("<p id='" + linename + "'>" + linename + " link1<\/a> link2<\/a><\/p>"); // on click tell me, which row you belong to $("#" + linename + " a").click(function() { alert("This is " + linename); }); } $(document).ready(function(){ makeTestLines($("body")); makeTestLines($("body")); makeTestLines($("body")); }); </script> </head> <body> <p>Click on the links to see, which line they belong to:</p> </body> </html> -------8<---------------------------------------------------------------- When you click on a link, it is expected to tell you, which line it belongs to. But every link seems to belong to Row3!? It looks as if "linename" is passed to the function by reference instead of by value. Can anybody explain that? And - more important - does anybody know a workaround? Thanks in advance, Ungebeten -- View this message in context: http://www.nabble.com/String-passed-by-value-or-by-reference-tp19401126s27240p19401126.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.