javascript - Array push and jQuery doesn't work -


i've piece of code. need create set of input elements , remove them all:

function inputreset(){       var td = new array();     $('#aaa').find('input').each(function(){         td.push($(this).parent());         alert(td[0][0].nodename);     });     alert(td[0][0]);     for(var = 0; < 2; i++){         var value = td[i].children('input').val();           alert(td[0][0].nodename);     }     try{         td.children('input').remove();         td.text(value);     }catch(err){         //alert($('#aaa').html())     } }  $('td[text="editable"]').click(function(){                   $('td[text="editable"]').unbind('click');                    inputreset();         $('td[text="editable"]').each(function(index){             if(index < 2){                 var value = $(this).text();                 $(this).html('<input type="text" name="i'+index+'" value="'+value+'" style="width: 100%" />');             }         });         $(document).keyup(function(e){             var keycode = (window.event) ? e.which : e.keycode;             if(keycode == 27)                 inputreset();          });     } ); 

i can't understand why first alert shows me 0 element pushed it, while second tell me "tdarray[0] undefined".

any ideas?

thx lot

this works me... 2 alerts div:

http://jsfiddle.net/ahallicks/e2eez/


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -