I have the following markup which I need to bind a click event to the <a> tag below.
How can i achieve this?
<p class="people_rt_link2" id="test">
<a href="#" title="2011">2011</a>
<p style="padding-left: 3px; margin: 3px 0px;">
a href="http://192.168.20.24/mclarengroup/archives/928">McLaren to build £10m Big Yellow in Chiswick, West London</a>
</p>
<br>
<a href="#" title="2010">2010</a>
<br>
</p>
This is my current javascript function:
<script type="text/javascript">
$(document).ready(function() {
$('.people_rt_link2 a').click(function() {
alert('aa');
});
var data = { cat_id:<?php echo $cat_id?>,posted_year:<?php echo $posted_year?>};
jQuery.post("<?php echo $ajax_page_details->guid?>", data, function(response) {
$('#test').html(response);
});
});
</script>
you could possible do it by setting an id for the link.
HTML:
Javascript:
Have a look at the jquery documantation specially for selectors:
http://api.jquery.com/category/selectors/