views:

20

answers:

2

I am added json object data and three buttons for every li tag in my webpage. My requirement is , I want to get that dynamically added button . But i am not getting that button by using $("but1").click(function(){ alert("hi iam getting dynamic added button"); });. So please give me some suggession to acheive this.

+3  A: 
$('#selector').live('click', function(){} )

Since they don't exist, you need to use live or delegate

meder
+1  A: 

You need the live() method for dynamic generated elements:

$("#but1").live('click', function(){
   alert("hi iam getting dynamic added button");
});

live()

Description: Attach a handler to the event for all elements which match the current selector, now or in the future.

Sarfraz