Get HTML in line: room["html"] = $(this).parents(".selectRowRoom").html();
and insert after load step-02.php
in .thisRoom
but this error is in Console.
$(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>")
}
});
});
})
And error in console is:
Uncaught TypeError: Cannot read property 'html' of undefined
This...
for(var i = 0; i <= lenHotel; i++)
Should be this
for(var i = 0; i < lenHotel; i++)
Your accessing an element in the array that doesnt exist.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.