Question: I am trying to retrieve the title attribute and replace the current paragraph text with it. Everything else about my script is working perfectly. The title attribute is coming back as "undefined". I am new to javascript and I have looked all over for answers... nothing that I am seeing so far. 

**JS:**

```
$(document).ready(function(){

    $('.thumbnails a').click(function(e){
        e.preventDefault();

        $('.thumbnails a').removeClass('selected');
        $('.thumbnails a').children().css('opacity','1');

        $(this).addClass('selected');
        $(this).children().css('opacity','.4');

        var photo_caption = $(this).attr('title');
        var photo_fullsize = $(this).attr('href');
        var photo_preview = photo_fullsize.replace('_large','_preview');

        $('.preview').html('<a href="'+photo_fullsize+'" title="'+photo_caption+'" style=background-image:url('+photo_preview+')></a>');

        $('.caption').html('<p><a href="'+photo_fullsize+'" title="'+photo_caption+'">View larger</a></p><p>'+photo_caption+'</p>');
    });
});

```

**HTML:**

```
<li>
   <a href="images/webdesign/indiePantry_large.jpg" target="_blank">
      <img src="images/webdesign/indiePantry_thumbnail.jpg" 
             width="160" height="160" title="Indie Pantry" />
   </a>
</li>

```

Answer: 
The title is on the image, not the `<a>` element:

```
var photo_caption = $('img', this).prop('title');

```
`this` is your `a` tag, and `a` has no `title` (img does)

try it through chrome and the f12 developer panel. You can set breakpoints in your javascript code and inspect what precisely `this` is at any time.