Dave, I was shocked when you got the first answer. I don't think there is
any way to get just the text using jQuery core functions.

If you get .html() you can use regexps to remove the complete nodes, it
seems messy.

if you write a plugin (there may already be one) it can go thru the dom
nodes and return the concatenation of the simple text nodes.

jQuery likes to shield us from the nastiness of the real dom objects and
incompatibilities of lesser browser.



On 5/29/07, DaveG <[EMAIL PROTECTED]> wrote:



I didn't find a way to do this yet, but I did discover a way to crash my
browser:

Warning: locks up FF2
   Input: <div id="id1"><p>here is</p> some text</div>
   jQ: $("#id1<").text()

I also discovered a way to get the text of the first element:
   Input: <div id="id1"><p>here is</p> some text</div>
   jQ: $("#id1>").text()
   Output: "here is"

~ ~ Dave

On Tue, 29 May 2007 15:48:30 -0400, DaveG <[EMAIL PROTECTED]> wrote:
>
>
> How do I find the first text-node of a given DOM object?
>
> Input: <div><p>here is</p> some text</div>
> Output: " some text"
>
> Input: <h1><a href="#id1"></a>Header 1</h1>
> Output: "Header 1"
>
>  ~ ~ Dave




--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ

Reply via email to