There must be a better way to select this element. Can someone please help me out. I've tried nth-child and last-child, but I'm not getting it.
Here's my code:
<li>
<div class="pic" style="width:300px; text-align:center;">
<img src='path/to/my/image.jpg' />
</div>
<p>
<span title="<?php echo $media_title; ?>">Title: <?php echo stringDisplay($media_title,12); ?></span><br />
<span title="<?php echo $media_filename; ?>">File: <?php echo stringDisplay($media_filename,18); ?></span><br />
Updated: <?php echo date("n/j/y", $lastUpdated).' at '.date("h:ia",$lastUpdated); ?>
</p>
<a class="link" href="javascript:;" onclick="alert($(this).parent().children('.pic').children().children().children().attr('src'));" style="margin-bottom:3px;">Preview</a>
</li>
I'm trying to select the image source of the image in the first div from the link below it. The best I could come up with is:
alert($(this).parent().children('.pic').children().children().children().attr('src'));