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 script below

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

So please give me some suggession to acheive this.

2 Answers 2

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.