In below fiddle is it possible to attach a listener to the vote button so that when vote is clicked a listener is fired, in this case just an alert ?
I’ve tried attaching the css to a listener but not working. :
$('.pds-return-poll').on('click', function () {
alert('here');
});
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".pds-pd-link").hide();
$(".a2a_dd.pds-share").hide();
});
</script>
<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script>
If you bind an event directly to a selector , the element must exist when the code fires. To delegate for future elements the event must be bound to a permanent asset in the page. WIth on() method you use the second argument as the target selector.
It appears you are adding elements with script after the click handler code is being fired
See full API docs for on()