I'm trying to invoke a click on first .loader child when document is ready, but no success:
html:
<a class="loader" data-target="david-boy" title="Danny Boy-Rivera">
<span class="img"><span class="play"></span><img src="img/gallery-image1.jpg" alt="" /></span>
<h2>Danny Boy</h2>
</a>
jQuery:
//Does not work
$('a.loader:first-child').bind('click');
$('a.loader:first-child').trigger('click');
$('a.loader:first-child').click();
//Works
$('a.loader:first-child').css("background", "red");
Any ideas why?
Update
Handler:
$('.loader').click(function(){
var name=$(this).data("target");
callVideo(name);
});
Update2
So the problem was that I had declared the :first-child action before the handler. I changed their places and everything ok