Xriuk Xriuk - 2 months ago 8
jQuery Question

How to select an anchor inside several other elements

I have this in my CSS:

#slider div.mc-caption a


How can I select this element via JQuery?

Thanks.

Answer

try this ... this is known as selector

console.log($('#slider div.mc-caption a'));
$('#slider div.mc-caption a').click(function()
        {alert('Testing')});

and with HTML

<div id="slider">
    <div class="mc-caption"><a href="javascript:void(0)">Testing</a></div>
</div>

Click here for fiddle