var ul = $(".display-movie");
for (var i = 0 ; i < response.movies.length; i++) {
var img = $("<img>").attr("src", response.movies[i].posters.thumbnail)
.css("width", "200px")
.css("height", "200px")
.css("margin", "20px")
.click(click_pressed);
var text = response.movies[i].title;
var row = $("<li> <div>");
var endrow = $("</div> </li>");
ul.append(row , img , text , endrow);
In the above code, the click function works well and displays and alert. But what I want is that when clicked the alert should display the ID of the object that was clicked so that later I can retrieve details of this object using its id.
function click_pressed() {
alert($(this.title));
}