Reputation: 593
<aside class="widget">
<h6 class="widget-title">Play List</h6>
<div class="newsletter">
<div class="nwlwrap">
<article class="post-item">
<div class="featured-image clearfix" >
<a href="http://vimeo.com/46163823" rel="prettyPhoto" class="link-thumbnails-video">
<img alt="" src="images/thumbs/video-1.jpg" class="thumbnails link-thumbnails-video">
</a>
<div class="image-caption">
<span>Posted 2012/07/18 </span>
</div>
</div>
<div class="entry-content">
<h3 class="entry-title"><a href="#">What is Kopatheme Layout Manager</a></h3>
<p>Vivamus. Sagittis facilisis hymenaeos scelerisque ad scelerisque. Massa felis odio rhoncus ligula sollicitudin Magna. Laoreet. Vel tristique tellus nam quis curae</p>
</div>
</article>
<div class="clear"></div>
<div class="kp-divider"></div>
</div>
</div>
</aside>
$(".widget").click(function(event){
$(this).find('.featured-image clearfix img').attr('id');
alert("hey");
});
I have a list of videos, I want when user clicks on one of the videos, then the clicked video, start playing in the video player. the jquery clicked function is not working, Kindly guide me in right direction.
Upvotes: 0
Views: 101
Reputation:
@Desire your JavaScript code isn't wrapped in a script tag. The fact that you haven't wrapped it, makes me wonder if you have jQuery included in you page at all? Also, as @adeneo points out, your object doesn't have any ID.
So wrap your script in script tags, and either make sure your object has an ID or find some other way to identify it. Also, you don't need to write:
$(this).find('.featured-image.clearfix img').attr('id');
Give the div and ID, it is a lot easier and will process a lot faster.
Upvotes: 0
Reputation: 318212
<div class="featured-image clearfix" >
That would be one element with two classes, and you'd target that like this:
$(".widget").click(function(event){
$(this).find('.featured-image.clearfix img').attr('id');
alert("hey");
});
using a space between the classes looks for something like:
<div class="featured-image"><div class="clearfix"></div></div>
Now if the image only had an ID, you'd get it ?
Upvotes: 2