I have a div which get's its content loaded through ajax .load("ajaxcontent.php").
Inside this div, we produce many other divs. I want to get the content of one of these divs.
I've tried var insidecontent=$('#topdiv').html(); but it returns null.
is there a trick to getting such values?
index.html
<div id="news"></div>
ajaxcontent.php
<div id="topdiv">Hello World</div>
<div id="middiv">This is the mid div</div>
<div id="botdiv">This is the bottom</div>
javascript:
$("#news").load("ajaxcontent.php");
$(document).delegate("#total", "keyup", function (e) {
if(e.which!=13){
var insidecontent=$('#topdiv').html();
}
});
Are you accessing the content after the load function completes its execution ?
$("#firstDiv").load("serverpage.aspx",function(){
// Now access the content
var insideContent=$("#topDiv").html();
});
EDIT : After the op posted his code
wrap the delegate binding inside document.ready like this
$(function(){
$(document).delegate("#total", "keyup", function (e) {
if(e.which!=13){
var insidecontent=$('#topdiv').html();
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With