Code to bind a function with an element in jQuery

Pgayath
Posted by Pgayath under jQuery category on | Points: 40 | Views : 1095
Div element is binded with a function to display message box when clicked on it.

<html>
<head>
<title>the title</title>
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('div').bind('click', function( event ){
alert("You have clicked me!');
});
});
</script>
<style>
.div{ margin:10px;padding:12px;
border:2px solid #666;
width:100px;
}
</style>
</head>
<body>
<p>Click on any square below to see the result:</p>
<div class="div" style="background-color:green;cursor:pointer;">Click Me!</div>
</body>
</html>

Comments or Responses

Login to post response