I keep getting this error in the $('#savetickets-list')
line. I want to dynamically add fields to a table, the table has the id in HTML.
<div class="savetickets-list">
</div>
In javascript I fill the table in a for loop
for (var i = 0; i < len; i++) {
// the data es from a web database
var ticketname = results.rows.item(i).iTicketName;
$('#savetickets-list').append('
<div class="saveticket gradient-top">
<h3>' + ticketname + '</h3>
</div>
');
}
I dont know how to solve this. jQuery is loaded, I also checked the name of the selector.
Please help.
I keep getting this error in the $('#savetickets-list')
line. I want to dynamically add fields to a table, the table has the id in HTML.
<div class="savetickets-list">
</div>
In javascript I fill the table in a for loop
for (var i = 0; i < len; i++) {
// the data es from a web database
var ticketname = results.rows.item(i).iTicketName;
$('#savetickets-list').append('
<div class="saveticket gradient-top">
<h3>' + ticketname + '</h3>
</div>
');
}
I dont know how to solve this. jQuery is loaded, I also checked the name of the selector.
Please help.
ticketname
? Can you post the contents of results.rows
in your question.
– Rory McCrossan
Commented
Jun 28, 2012 at 7:54
id
: $('#savetickets-list')
, while you have class="savetickets-list"
in your markup.
– Jared Farrish
Commented
Jun 28, 2012 at 7:55
$('#savetickets-list').append('\
<div class="saveticket gradient-top">\
<h3>' + ticketname + '</h3>\
</div>\
');
when you want to write multiline strings in JS, you must escape new lines.
It is because you are using new lines.
JS does not automatically read new lines for you. It treats them as new statements.
The way I prefer to do this is like:
$('#savetickets-list').append('<div class="saveticket gradient-top">'+
'<h3>' + ticketname + '</h3>'+
'</div>');
Just checked. The problem is in the newlines, you have to concatenate strings or put all the statement in a single line.