How to find dynamically added html control using JQuery

gustavoc

New Member
I have a literal control on my ASP.Net web page. In my code behind function, I am assigning a javascript block to this literal's Text. This script block points to a website URL which returns a html output back to the literal and as a result it gets rendered on my page dynamically.Page HTML\[code\]<asp:Literal runat="server" ID="MyLiteral" EnableViewState="False"></asp:Literal>\[/code\]Code behind\[code\]MyLiteral.Text = String.Format(@"<script type='text/javascript' src='http://mywebsite/gethtml'></script>";\[/code\]After this page loads completely, I want to access one of the html elements, say DIV (dynamically created above) using JQuery code like this\[code\]alert($('#mydynamicdiv').attr('id'));\[/code\]However, this alert returns undefined. Why does this happen basically, and how can I access the dynamic elements here?
 
Back
Top