Code to bind a function with an element in jQuery

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

<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!');
.div{ margin:10px;padding:12px;
border:2px solid #666;
<p>Click on any square below to see the result:</p>
<div class="div" style="background-color:green;cursor:pointer;">Click Me!</div>

Comments or Responses

Login to post response