jQuery .click() event for multiple div's
I have some search results that I'm outputting that are of this form:
  

      <div id="result" title="nCgQDjiotG0"><img src="http://i.ytimg.com/vi/nCgQDjiotG0/default.jpg"></div>

There is one of these for each result. I'm trying to detect which one is clicked and then do some stuff. Each result has a unique title, but the same id. How do I use .click() to know which one was clicked so I can get it's ID and use it?

Here's how I'm getting the HTML from above:

    $.each(response.data.items, function(i,data)
    {
    var video_id=data.id; 
    var video_title=data.title; 
    var video_thumb=data.thumbnail.sqDefault; 
    
    var search_results="<div id='result' title='"+video_id+"'><img src='"+video_thumb+"'></div>";
    $("#searchresults").append($(search_results));

I tried

     $('div').click(function(){
        alert(this.id);
    });

and the alert says "searchresults" (no quotes).
jQuery .click() event for multiple div's
===

I have some search results that I'm outputting that are of this form:
  

      <div id="result" title="nCgQDjiotG0"><img src="http://i.ytimg.com/vi/nCgQDjiotG0/default.jpg"></div>

There is one of these for each result. I'm trying to detect which one is clicked and then do some stuff. Each result has a unique title, but the same id. How do I use .click() to know which one was clicked so I can get it's ID and use it?

Here's how I'm getting the HTML from above:

    $.each(response.data.items, function(i,data)
    {
    var video_id=data.id; 
    var video_title=data.title; 
    var video_thumb=data.thumbnail.sqDefault; 
    
    var search_results="<div id='result' title='"+video_id+"'><img src='"+video_thumb+"'></div>";
    $("#searchresults").append($(search_results));

I tried

     $('div').click(function(){
        alert(this.id);
    });

and the alert says "searchresults" (no quotes).