<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js">
$(document).ready(function(){
$("#div1").on("click","p",function(){
$(this).css("background-color","pink");
$("#div2").delegate("p","click",function(){
$(this).css("background-color","pink");
<h4 style="color:green;">This example demonstrates how to achieve the same effect using on() and delegate().</h4>
<p>Click to set background color using the <b>on() method</b>.</p>
<p>Click to set background color using the <b>delegate() method</b>.</p>