I have dynamically generated div from the below code in partial view.
$('#album').click(function (e) {
var l = window.location;
var base_url = l.protocol + "//" + l.host;
e.preventDefault();
$.ajax({
type: "POST",
url: base_url + '/CreateAlbum/DisplayAlbum',
success: function (data) {
$.each(data, function (index, el) {
console.log(el);
for (i = 0; i < el.length; i++) {
div = $('<div class="albumclass" />');
**img = $('<img src="/Content/images/fold.jpg" width=150 height=150 assigned-id ='+el[i]["ID"]+'/>').prependTo(div);**
lbl = $('<label/>').text(el[i]["title"]).appendTo(div);
div.appendTo('.album_inner');
}
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert("Error");
}
});
});
I need to catch the value of 'assigned-id' of current double clicked image in jquery.I tried the below code but result 'undefined'
$('.album').on('dblclick', '.albumclass img', function (e) {
$("#albumId").val($(this).data('assigned-id'));
});
Anybody please help