Reputation: 53
I have some code on my page like:
$(document).ready(function(){
//code
});
And on jQuery ready, there is a code to get a div inner HTML:
var tmp = document.getElementById("content").InnerHTML;
It returns undefined. As I know jQuery ready runs when page HTML is completely loaded. But it can't just find div!
jQuery including and div id are correct.
Any ideas?
Upvotes: 0
Views: 1497
Reputation: 1804
If you're using jQuery already, why not use it to find your DOM element? Assuming your div has an ID of "content":
$(document).ready(function(){
var $tmp = $("#content"),
html = $tmp.html();
});
Upvotes: 2
Reputation: 1644
var tmp = document.getElementById("content").InnerHTML;
This would work, except InnerHTML is not a property of HTMLElement. You simply misspelt innerHTML.
Try
v
var tmp = document.getElementById("content").innerHTML;
^
Upvotes: 6