<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery UI Button - Icons</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style>
#s
{
width:200px;
}
#div1
{
min-width:100px;
width:auto;
float:left;
border:2px solid black;
min-height:100px;
height:auto;
background-color:red;
}
</style>
<script>
$(document).ready(function(){
$("div").click(function(){
$(this).after($('<div id="s" style="background-color:blue;">NLC TRANSPORT</div>'));
});
$("#s").click(function(){
alert("sljsdf");
});
});
</script>
</head>
<body>
<div id="div1">
VOLVO B9R
</div>
</body>
</html>
Here when i click on the first div, the program creates another div. the newly created div is not responding to on click event. in the current code i have specified that the newly created div should give an alert on click but its not working. Thanks!