Here my solution:

$('p').click(function() {
$('p span').replaceWith(' ') // stripes the span element from paragraphs.
  alert($(p).text()); // shows the paragraphs text 'free' of spans.
});

Mauricio

-----Mensagem Original----- De: <[EMAIL PROTECTED]>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: domingo, 28 de setembro de 2008 17:10
Assunto: [jQuery] Re: select data in a <p> ignoring the <span>



      I tested but it had two Problems
1- It Removes the Span so the solution us Make A CLONE from it
2- it Result is the Text in the Span which we don't need that so we
have to put and End(). to return to the code in below works :

I change the Code to this :

    var newP=$("p").clone();
    newP.find("span").remove().end().text();

does anyone has a better idea
by the Way thanks MorningZ

Thanks Pedram

On Sep 28, 10:56 pm, MorningZ <[EMAIL PROTECTED]> wrote:
that wouldn't remove the span,as the expression $(txt) creates a new
and not-on-the-DOM object, removing the span would do so just from the
jQuery object

On Sep 28, 3:51 pm, [EMAIL PROTECTED] wrote:

> Dear MorningZ ,
> I don't want to remove the Span I just want to filter the text before
> the Span ...
> Pedram

> On Sep 28, 10:22 pm, MorningZ <[EMAIL PROTECTED]> wrote:

> > this is TOTALLY untested, but should work
> > $("p").click(function() {
> > var txt =$(this).html();
> > txt = $(txt).find("span").remove().text();
> > alert(txt);
> > );

> > On Sep 28, 2:13 pm, [EMAIL PROTECTED] wrote:

> > > Hi Guys,

> > > this is the Code which I am working on

> > > <p>
> > > Data which I need to select and it hasn't an attribute
> > > <span> Data in a Span </span>
> > > </p>
> > > <p>
> > > Data which I need to select and it hasn't an attribute
> > > <span> Data in a Span </span>
> > > </p>
> > > <p>
> > > Data which I need to select and it hasn't an attribute
> > > <span> Data in a Span </span>
> > > </p>
> > > How could FIlter and Select the text Before the <span>
> > > does someone has an Idea ?

Reply via email to