Simple JQuery problem, what am I missing?
Hello all,
I have a really simple situation where I want to read a html page and then pull a div from it, but I can't :-(
I'm sure it's a really easy problem but I can't see why it doesn't work.
Can someone take a look and point me in the right direction?
- <html>
<head>
<script language="JavaScript" type="text/javascript" src="jquery-1.4.2.js"></script>
<script language="JavaScript" type="text/javascript">
$.ajax({
url: 'logs.html',
success: function(data) {
var jQueryObject = $(data);
var div = jQueryObject.find("#logs");
alert(div.html().length);
}
</script>
</head>
<body>
<div id="logs" style="width: 100%; height: 200px; border: 1px solid black; overflow: scroll;"></div></body></html>
The background page is...
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<div id="logs">test test test</div>
</body>
</html>
It's driving me nuts but this surely is something really simple.
I just want to read in the div called logs, and then read out it's length in chars.
Help please?