I have a link that looks like this:
<p class="half_text"><?php echo $upvotes; ?> <strong>
<a id="vote_up" style="color: #295B7B; font-weight:bold;" href="">Vote Up</a>
</strong> | <?php echo $downvotes; ?> <strong>
<a id="vote_down" style="color: #295B7B; font-weight:bold;" href="">Vote Down</a>
</strong></p>
and some jQuery code that I am trying to get called.
<script type="text/javascript">
$('#vote_up').click(function()
{
alert("up");
});
</script>
But for some reason the alert does not fire when the vote up or down links are pressed. Any idea what I am doing wrong?
You can see this for yourself here: http://www.problemio.com
You need to place your code inside the
.ready()handler:Take a look at the
.ready()docs: http://api.jquery.com/ready/Here’s a working jsFiddle.