What about doing is client-side? So cycle through each line with each() and then use .wrap("<span></span>"). This will put into the DOM what you need to use later.
Also, you might be interested in this plugin. http://www.jquery.info/The-plugin-SearchHighlight It finds text based on search criteria in a large block of random text. It might be useful. Glen On Tue, May 6, 2008 at 6:44 PM, darren <[EMAIL PROTECTED]> wrote: > > oh man, i wish i could do as you suggested, that was my first idea and > it would make things so much easier. However, the code i'm working > with is markup of Shakespeare's works. Its incredibly complex and we > use Cocoon to generate these pages from xml. long story short, my > employer can't afford to make such a change now so I have to make due > with what's there. I think i came up with a reasonable solution > though: > > 1. Find the div with the lower tln value. Then get its index with > respect to the parent. > 2. Find the next highest div tln and get its index as well. > 3. From this we know the text node lies within the indexes, so search > for the text there. > > Again, because of the code complexity, this does not always work, but > at least i'm making progress. Thanks for your insight though. > > > > On May 6, 9:28 am, "Glen Lipka" <[EMAIL PROTECTED]> wrote: > > I tried to cut corners by skimming your html. I see it now. The divs > close > > and the text is after the div. > > This is really strange HTML to me. Why not just put the text inside the > > div? Or just wrap the text inside a span? > > If you wrap the text inside spans, then the jQuery is pretty simple. I > > whipped up a sample. > > > > http://commadot.com/jquery/findTextElements.php > > > > $("#tln21").next("span").addClass("highlight") > > > > Sometimes, fancy JS is not as good as clean html. > > > > Glen > > > > On Mon, May 5, 2008 at 6:51 PM, darren <[EMAIL PROTECTED]> wrote: > > > > > hi glen, thanks for replying. > > > > > That still wouldn't work. With that you are looking for the text > > > inside div elements which are descendants of of the id'd element. > > > What i want to select are certain text elements of the id'd element. > > > I figured something out, but this is surprisinlgy difficult: > > > > > <div id="21"> > > > <div> > > > <text node> > > > <div> > > > <text node> > > > ... > > > </div> > > > > > I had to use .contains() and [nodeType=3] to pick text nodes. not > > > pretty. > > > > > On May 5, 4:23 pm, "Glen Lipka" <[EMAIL PROTECTED]> wrote: > > > > $("#tln21 div").text(); > > > > > > Like that? By the way, firebug is very helpful to test our selectors > and > > > > see what they come up with. > > > > Hmm, it would be nice to have a tutorial on how to do this. I can > try > > > and > > > > whip one up. > > > > > > Glen > > > > > > On Mon, May 5, 2008 at 2:47 PM, darren <[EMAIL PROTECTED]> wrote: > > > > > > > hi Joe, thanks for your comment > > > > > > > If you look closer, you can see that the text is not actually in > the > > > > > div element. i basically need to select the text after that node: > > > > > > > <div> > > > > > <div tln=xxx></div> > > > > > Some text > > > > > <div tln=xxx></div> > > > > > some more text > > > > > <div tln=xxx3></div> > > > > > even more text > > > > > </div> > > > > > > > So that wouldnt work > > > > > > > On May 5, 2:06 pm, Joe <[EMAIL PROTECTED]> wrote: > > > > > > $("#tln21').text(); > > > > > > > > This will return the text associated with id="tln21". > > > > > > > >http://docs.jquery.com/Attributes/text > > > > > > > > Joe > > > > > > > >www.subprint.com > > > > > > > > On May 5, 2:34 pm, darren <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi everybody, new member here. > > > > > > > > > I have a project with the following snipped of code: > > > > > > > > > =====start html===== > > > > > > > <div class="line"> > > > > > > > <div name="tln4" id="tln4" > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>As I remember, Adam, it was > > > upon > > > > > > > this fashion > > > > > > > <div name="tln5" id="tln5" > class="ln > > > > > > > tln">5</div>bequeathed me by will but poor a thousand > > > > > > > <div name="tln6" id="tln6" > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>crowns, and, as thou > say'st, > > > > > > > charged my brother, > > > > > > > <div name="tln7" id="tln7" > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>on his blessing, to breed > me > > > well; > > > > > > > and > > > > > > > <div name="tln8" id="tln8" > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>there begins my sadness. My > > > > > > > brother Jaques he keeps > > > > > > > <div name="tln9" id="tln9" > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>at school, and report > speaks > > > > > > > goldenly of his profit. > > > > > > > <div name="tln10" id="tln10" > > > class="ln > > > > > > > tln">10</div>For my part, he keeps me rustically at home, or, > to > > > > > > > speak > > > > > > > <div name="tln11" id="tln11" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>more properly, stays me > here at > > > > > > > home unkept; for call > > > > > > > <div name="tln12" id="tln12" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>you that "keeping" for a > > > gentleman > > > > > > > of my birth that differs > > > > > > > <div name="tln13" id="tln13" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>not from the stalling of an > ox? > > > > > > > His horses are bred > > > > > > > <div name="tln14" id="tln14" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>better, for, besides that > they > > > are > > > > > > > fair with their feeding, > > > > > > > <div name="tln15" id="tln15" > > > class="ln > > > > > > > tln">15</div>they are taught their man�ge, and to that end > riders > > > > > > > <div name="tln16" id="tln16" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>dearly hired; but I, his > > > brother, > > > > > > > gain nothing under > > > > > > > <div name="tln17" id="tln17" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>him but growth, for the > which > > > his > > > > > > > animals on his > > > > > > > <div name="tln18" id="tln18" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>dunghills are as much bound > to > > > him > > > > > > > as I. Besides this nothing > > > > > > > <div name="tln19" id="tln19" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>that he so plentifully > gives > > > me, > > > > > > > the something that > > > > > > > <div name="tln20" id="tln20" > > > class="ln > > > > > > > tln">20</div>nature gave me his countenance seems to take from > > > > > > > <div name="tln21" id="tln21" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>me. He lets me feed with > his > > > > > > > hinds, bars me the > > > > > > > <div name="tln22" id="tln22" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>place of a brother, and as > much > > > as > > > > > > > in him lies, mines my > > > > > > > <div name="tln23" id="tln23" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>gentility with my > education. > > > This > > > > > > > is it, Adam, that > > > > > > > <div name="tln24" id="tln24" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>grieves me; and the spirit > of > > > my > > > > > > > father, which I think > > > > > > > <div name="tln25" id="tln25" > > > class="ln > > > > > > > tln">25</div>is within me, begins to mutiny against this > servitude. > > > > > > > <div name="tln26" id="tln26" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>I will no longer endure it, > > > though > > > > > > > yet I know no wise > > > > > > > <div name="tln27" id="tln27" > > > class="ln > > > > > > > tln"> > > > > > > > <!----> > > > > > > > </div>remedy how to avoid it. > > > > > > > <!----> > > > > > > > </div> > > > > > > > ====End HTML==== > > > > > > > > > I have a short selection of text and a tln that the text should > be > > > > > > > found near. I wan to use jquery to find this text node so that > i > > > can > > > > > > > manipulate it. My trouble is that I dont understand how the > DOM > > > > > > > treats text nodes and element nodes. > > > > > > > > > So say for example i had the information (tln21) and a text > snippet > > > > > > > "He lets me". What i tried was: > > > > > > > $("#tln21').siblings() > > > > > > > But this is only returning element siblings, not text siblings. > > > > > > > > > what can i do here? thanks for any help. >