2016-10-08 7 views
0

取得HTML:room["html"] = $(this).parents(".selectRowRoom").html();.thisRoomに負荷step-02.php後に挿入しますが、このエラーはコンソールです。コンソールでエラー(Chromeブラウザ)

$(function() { 
var hotel = []; 
var lenHotel = 0; 
$('#forPrice').on('click', function() { 
    $('select').each(function() { 
     if($(this).val() > 0 && $(this).val() < 10) { 
      var room = {}; 
      room["room"] = $(this).attr('room'); 
      room["price"] = $(this).attr('price'); 
      room["val"] = $(this).val(); 
      room["html"] = $(this).parents(".selectRowRoom").html(); 

      hotel.push(room); 
     } 
    }); 
    lenHotel = Object.keys(hotel).length; 
    console.log(hotel); 
}); 

$('#forPrice').click(function() { 
    $('#Step-01').hide(); 
    $('#Step-02').show(); 
    $('.hiddenAndShow').hide(); 
    $("#Step-02").load('step_02', function() { 
     for(var i = 0; i <= lenHotel; i++) { 
      $("#Step-02").find('.thisRoom').append("<tr class=\"selectRowRoom\">"); 
      $("#Step-02").find('.thisRoom').append(hotel[i]['html']); 
      $("#Step-02").find('.thisRoom').append("</tr>") 
     } 
    }); 
}); 
}) 

とエラーです:

Uncaught TypeError: Cannot read property 'html' of undefined 
+0

あなたはここで何をしていますか、あなたはHTMLの親htmlを取得しようとしていますか?その場合、HTMLはスーパーの親であり、親を持たないため動作しません。 –

答えて

1

この...

for(var i = 0; i <= lenHotel; i++) 

この

for(var i = 0; i < lenHotel; i++) 

あなたはdoesntの配列の要素にアクセスすることがすべき存在する。

関連する問題