views:

175

answers:

2

I have a web page with one button and one div

If you click this button that will load another button into the div using jQuery

I found that the new button -which is loaded in runtime - will not be effected by other jQuery statements.

how can I apply jQuery statements to elements that are loaded in runtime?

I wish It is clear! if not I will try to give an example!

Thanks and best regards

+3  A: 

If you are attaching an event to a selector that matches something in the dynamically loaded DIV before the DIV is loaded, you need to use jQuery's live functionality so that it knows to look for new content to attach these handlers to. If that's not your problem, I'm not sure what you're asking.

Paolo Bergantino
this is what I was looking for, Thanks
ahmed
A: 

Simply bind events to the new button when it's loaded:

$(element).bind("click", function(){ //enter code for the new button })

Stiropor