Why my element always return the same value in js?

It's because of clousres/variable scoping, your tmpItem. M_sId var will get only its last value. But if you do.

It's because of clousres/variable scoping, your tmpItem. M_sId var will get only its last value. But if you do: $("#edit_"+tmpItem.

M_sId). Bind('click', function(){ alert($(this). Attr("id")); }); you will surely get different results.

EDIT Just in case you need to acces to your tmpItem inside your click event, you could use . Data as this: for(var I = 0; I for me to handle the event tmpItem.toHTMLElement(). PrependTo($("#main")); //bind the click event $("#edit_"+tmpItem.

M_sId). Data("tmpItem", tmpItem). Bind('click', function(){ var tmpItem = $(this).

Data("tmpItem"); alert(tmpItem. M_sId); }); } Hope this helps. Cheers.

You are right, because the event is fired only after the for is completed. – morgar May 7 at 3:11 @morgar Exactly – Edgar Villegas Alvarado May 7 at 3:19 one more question... If I have two elements, for example, the when the $("#edit_"+tmpItem. M_sId) click, need to change somethings in $("#textarea_"+tmpItem.

M_sId), but I can't using the "this" keywords, how can I do? Thank you. – Tattat May 7 at 10:30.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions