I'm writing some jquery to programmatically build a list of links and I'd like to attach a click() event to each link. I'm having trouble getting the click function to fire. Can anyone point me in the right direction on how to do this?
This is what I have so far:
<!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript" src="helper/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var markup = '<li><a href="#myLink1">some link</a></li>';
var $newLink = $(markup);
$newLink.appendTo('.myLinks ul');
$newLink.show();
$("ul.myLinks li").click(function() {
alert('hello');
});
});
</script>
</head>
<body>
<div class="myLinks">
<ul>
</ul>
</div>
</body>
</html>