To start with this. I have an associative array named $body
(PHP).
Let's say I want to get the value of $body[1]
or $body[2]
, depending on the id
of an element.
So here's my code.
$(document).ready(function() {
$('.messages').on('click', function() {
var id = $(this).attr('id');
$('#generic-modal-title').html('Message Preview');
$('#generic-modal-body').html('" . $body[-concatenate id here-] . "');
});
})"
What I tried doing (doesn't work):
$('#generic-modal-body').html('" . $body["id"] . "');