<html>
<head>
<script src="../jquery.js" type="text/javascript"> </script>
<script type="text/javascript">
$(".demo").click(function() {
alert("JavaScript Demo");
});
</script>
</head>
<body>
<p class="demo">a paragraph</p>
</body>
</html>
Why did not the click function response?
Thanks.
You are running the code too early. You should wrap it in a document-ready handler, which jQuery supports thus:
This will ensure that your code runs after the document is loaded.