[jQuery] Find: Looks simple, but isn't working as expected...
Narrative:
I'm trying to scrape a Wiki page within my company, extract the header
text only, then include that into the home page on our Intranet.
I thought: easy! I load the Wiki page into separate DOM starting at
the Div containing the actual content, find all the 'h3' elements, and
for each one, extract the text and append to a Div on my home page.
Sounds simple, but for the life of me, I can't get things to work
right...
1) the find() isn't working. When it's in, it finds nothing.
2) the empty() isn't working; the 'span' is what's handed to me when
I remove the 'find()' filter.
Any ideas how to do what I'm trying to accomplish? Less importantly,
what am I misunderstanding about the code shown below?
Thanks for the help-
Jeff
- - - - - - - - - - - - - -
<head>
{snip}
$(document).ready(function(){
$("#loadpage").empty() ;
var myDOM = new jQuery("<span/>") ;
myDOM.empty() ;
var mydata = myDOM.load("/jamwiki/en/TechTesting #content-
article") ;
mydata.find("h3").each(function(i) {
alert("Got one!" ) ;
$("#loadpage").append($(this)) ;
return true ;
} ) ;
});
{snip}
<head>
{snip}
<body>
<h1>Here's the Upcoming Tech Testing Events:</h1>
Test<div id="loadpage">hello jeff!</div>
</body>
- - - - - - - - - - - - - -
"load"ed document:
{snip}
<div id="content-article" class="clearblock">
<div style="font-size:90%;float:right;margin-left:5px;">[<a href="/
jamwiki/en/Special:Edit?topic=TechTesting&section=1">Edit</a>]</
div><a name="9/17_:_Space_check"></a>
<h3>9/17 : Space check</
h3>
<dl><dd>We WILL be running a full 8 hours of trades in the Tech Test
environment, making sure that space exists. HOWEVER, this WILL NOT
be a performance test, so you are welcome to continue development/
testing (ain't you lucky). We will probably begin the trades at
5:30PM.
</dd></dl><div style="font-size:90%;float:right;margin-left:5px;">[<a
href="/jamwiki/en/Special:Edit?topic=TechTesting&section=2">Edit</
a>]</div><a name="9/18_:_NON-Performance_test"></a>
<h3>9/18 :
NON-Performance test</h3>
<dl><dd>We will again be running a NON-Performance test in the Tech
Test environment, particularly the Finalization processes.
{snip}
- - - - - - - - - - - - - -