$(document).ready(function() { $("#example div").click(function() { var index = $("#example div").index(this); $("#example_index").html("Index " + index + " was clicked"); }); });