code.youlikeshare.com

Your code runs without problem with the below jquery code.

<!DOCYTYPE html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
	$(document).ready(function(){
		$("#clickme").click(function(){
			alert("you click me");
		})
	});
</script>
</head>
<body>
	<div id="clickme" style="width:200px; height:30px; background-color:#00f; margin:10px; padding:10px; text-align:center;">Click Me</div>
</body>
</html>

However, if the div (Click Me div) was dynamically created, the click event will not be fired for the above implementation. You need to directly delegate the event using $(document).on() method. See the below example. It will works.

<!DOCYTYPE html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
	$(document).ready(function(){
		$("#generate").click(function(){
			//dynamically create a new div
			$("#dynamic").html('<div id="clickme2" style="width:200px; height:30px; background-color:#00f; margin:10px; padding:10px; text-align:center;">Click Me 2</div>');
		})
	});
	
	$(document).on("click", "#clickme2", function(){
		alert("You click me");
	});
</script>
</head>
<body>
	<div id="generate" style="width:200px; height:30px; background-color:#00f; margin:10px; padding:10px; text-align:center;">Generate a DIV</div>
	<div id="dynamic">
	
	</div>
</body>
</html>