Skip to content

Instantly share code, notes, and snippets.

@akinsgre
Created August 19, 2011 13:34
Show Gist options
  • Save akinsgre/1156801 to your computer and use it in GitHub Desktop.
Save akinsgre/1156801 to your computer and use it in GitHub Desktop.
Assigning click events to dynamically loaded content.
<html>
<head>
<script src="javascripts/jquery-1.6.2.js" type="text/javascript" ></script>
<script type="text/javascript">
$(function() {
$('input').click(function(event) {
alert("This worked ..." + event.type);
});
$("#content").html("<input type='button' value='Loaded later'/>");
});
</script>
</head>
<body>
<p>This is a test</p>
<input type="button" value="Out of Div"/>
<div id="content"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment