jQuery Live() Demo

by Bharat Sewani

HTML

<div id="items">   
      <a id="first">first item</a><br/>
      <a id="second">Second item</a><br/>
      <a id="third">third item</a><br/>    
    </div>
         <input type="button" onclick="AddItems()" value="Add Items"/>
<p>Clicked on the items, we will get alert, we also get alert for newly added items</p>

JavaScript

$(document).ready(function() {
            $('#items a').live('click',function() {
                alert('hiii');
            });
            
        });
        
        AddItems=function () {
            $('#items ').append('<a>new item added </a><br/>');
        }