I am storing image tags in an ArrayList but my code doesn’t work and it is pretty simple, dunno why.
var total_Events = [];
var img =
$('<img>', {
'title': 'Title_1 (Event '+wavy_counter+')',
'class': 'listed_event',
'id': 'wavy_event_'+wavy_counter+'',
'data-count': ''+wavy_counter+'',
'src': 'final_buttons/test.png',
'height': '50',
'width': '50',
'onclick': 'highlight.call(this);',
'data-start': '',
'data-end': ''
});
img.appendTo('#event_list_main');
//Storing Event
store_event(img);
and the store_event function:
function store_event(event)
{
total_Events.push(event);
};
When I print the array I get nothing.
EDIT: Print Code
$('#test').click(function()
{
for(var i=0;i<total_Events.length;i++){
document.write(total_Events[i]);
}
});
The code adding the img to the array is good. Just make sure that the function
store_eventis defined before the code calling the function. And make verify thatwavy_counteris defined.