Code below doesn’t work on any browser. It’s supposed to show an alert box. What am I doing wrong?
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script type="text/javascript">
$('#prevlink').click(function () {
alert("Test");
});
</script>
</head>
<body>
<a id="prevlink" href="#">test</a>
</body>
</html>
You are not wrapping the function in a
ready()event. It runs before the DOM exists.