For sure, childNodes is the way to go if its always constantly going
to be like that, another possibility is to regex it
$("p").html().match(/.+(?=<.+?>.+<\/.+?>)/)
and if you wanted text on the other side of the span you could do
it like this ** javascript regex doesn't support lookbehind so y
you can let the var go:
$('p').each(function(){
if (this.firstChild.nodeName.toLowerCase() !="span")
$(this.firstChild).wrap("").parent().css('color','red');
});
and less fail-safe but shorter (can catch the span if there is no text
and the span is also empty):
$('p').each(function(){
Dear folks ,
finally this is what I got
$(p).each(function(){
if(this.childNodes[0].nodeName.toLowerCase() !="span")
var newNode=$(this.childNodes[0]).wrap("");
newNode.css('color','red');
});
this is the shortest code , basically you can not treat as a SELECTOR
If you are 100% sure that the will always come AFTER the text
data, like your example format, you could simply do:
$('#paragraph')[0].childNodes[0];
or
$('p').each(function(){
var data = this.childNodes[0];
});
- ricardo
On Sep 30, 5:34 pm, equallyunequal <[EMAIL PROTECTED]> wrote:
> Here
Here's a better version of that:
http://joeflateau.net/playground/testingpexcspan2.html
$( function(){
console.log($($
("p").childNodesExclusive("span")).allDOMNodesToHTML());
});
// this function returns all child nodes for the given element,
excluding those that have a property that m
NodeTypeNamed Constant
1 ELEMENT_NODE
2 ATTRIBUTE_NODE
3 TEXT_NODE
4 CDATA_SECTION_NODE
5 ENTITY_REFERENCE_NODE
6 ENTITY_NODE
7 PROCESSING_INSTRUCTION_NODE
8 COMMENT_NODE
9 DOCUMENT_NODE
10 DOCUMENT_TYPE_NODE
11 DOCUMENT_FRAGM
Wow amazing... it worked let me ask you question I think I can do it
with jQuery ..
do you know what does node.nodeType mean in javascript
nodeType=1 what does that mean for each value ?
thanks Pedram
On Sep 30, 8:29 pm, equallyunequal <[EMAIL PROTECTED]> wrote:
> I'm not sure how to do it in a "
I'm not sure how to do it in a "jQuery" way. But here's what I came up
with:
$( function(){
$("p").each( function() {
var allButSpan = this.allButSpan = new Array();
$.each(this.childNodes, function(i, node) {
if (node.nodeName.toLow
Dear Eric ,
It didn't work
$(this).contents() filters the span so when you configure the code to $
(this).contents().not('span') it returns Null
I wonder how come jQuery doesn't have a something lilke --ignore--
built in forexample .. so we could have ignored all the SPANs !!!
On Sep 30, 8:02 pm,
I apologize, I haven't tested this code:
$('p').each( function () {
alert( $(this).contents().not('span').text() );
});
On Sep 30, 12:20 pm, Pedram <[EMAIL PROTECTED]> wrote:
> It didn't work Cause the Text isn't concern as a Children and it is in
> No Tag area so when we call $(this).
It didn't work Cause the Text isn't concern as a Children and it is in
No Tag area so when we call $(this).children it returns only the
Span and if we do $(this).children(":not(span)") it returns NULL ...
so Equally. what should we do
On Sep 30, 5:34 pm, equallyunequal <[EMAIL PROTECTED
Ok, how about something to the effect of:
$("p").each(function() { $
(this).children(":not(span)").css({color:"red"}); });
On Sep 30, 8:12 am, [EMAIL PROTECTED] wrote:
> If I do this with CLone then all my prossesing is with the clone but I
> need to have a selector in the Original one not in th
If I do this with CLone then all my prossesing is with the clone but I
need to have a selector in the Original one not in the Clone so
changing and modifying the clone is not necessary ,the only way is get
a Clone of THe Span Then Remove the Span and then get the content of
the P do some changes o
$("p:not(span)") would select all paragraphs that are not spans...
which would be all paragraphs even if they have a child that is a
span.
$("p :not(span)") or $("p *:not(span)") would select all paragraphs
without child spans... which would be none of the paragraphs.
He needs the contents of all
um cant you just do something like $("p:not(span)") ??
On Sep 28, 3:48 pm, equallyunequal <[EMAIL PROTECTED]> wrote:
> This should work:
>
> var clone = $("p").clone();
> clone.find("span").remove();
>
> clone.each( function() { console.log(this) } );
>
> On Sep 28, 2:13 pm, [EMAIL PROTECTED] wro
;free' of spans.
>
> });
>
> Mauricio
>
> -Mensagem Original-
> De: <[EMAIL PROTECTED]>
> Para: "jQuery (English)"
> Enviada em: domingo, 28 de setembro de 2008 17:10
> Assunto: [jQuery] Re: select data in a ignoring the
>
> I tes
This should work:
var clone = $("p").clone();
clone.find("span").remove();
clone.each( function() { console.log(this) } );
On Sep 28, 2:13 pm, [EMAIL PROTECTED] wrote:
> Hi Guys,
>
> this is the Code which I am working on
>
>
> Data which I need to select and it hasn't an attribute
> Dat
> alert($(p).text()); // shows the paragraphs text 'free' of spans.
>
> > > > });
>
> > > > Mauricio
>
> > > > -Mensagem Original-
> > > > De: <[EMAIL PROTECTED]>
> > > > Para: "jQuery (English)"
') // stripes the span element from
> > > paragraphs.
> > > alert($(p).text()); // shows the paragraphs text 'free' of spans.
>
> > > });
>
> > > Mauricio
>
> > > -Mensagem Original-
> > > De: <[EMAIL PRO
') // stripes the span element from
> > > paragraphs.
> > > alert($(p).text()); // shows the paragraphs text 'free' of spans.
>
> > > });
>
> > > Mauricio
>
> > > -Mensagem Original-
> > > De: <[EMAIL PRO
;
> > -----Mensagem Original-
> > De: <[EMAIL PROTECTED]>
> > Para: "jQuery (English)"
> > Enviada em: domingo, 28 de setembro de 2008 17:10
> > Assunto: [jQuery] Re: select data in a ignoring the
>
> > I tested but it had two
TECTED]>
Para: "jQuery (English)"
Enviada em: domingo, 28 de setembro de 2008 17:10
Assunto: [jQuery] Re: select data in a ignoring the
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
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();
Ah I have found something:
$("p").contents();
I would prefer the useage of this like the following:
$("p").each(function() {
console.log( $(this).contents()[0] );
// with plain javascript:
console.log( this.firstChild );
});
On 28 Sep., 21:56, MorningZ <[EMAIL PROTECTED]> wrote:
> that w
Hmm... maybe you should use some plain Javascript:
$("p")[0].firstChild;
A bit extended:
$("p").each(function() {
console.log( this.firstChild );
});
would log all the texts from the Ps but not the texts inside the SPAN.
Maybe this helps...
On 28 Sep., 21:51, [EMAIL PROTECTED] wrote:
> Dea
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
> th
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("sp
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
>
>
> Data which I need
28 matches
Mail list logo