[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread comslash.com

Try this.

$('articlep:last').replaceWith($(this).html());


On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:
 is it possible to use jQuery to strip a tag from a 'div' ?

 example:

 article
 phello world/p
 plast paragraph/p
 /article

 I would like strip the p tags from 'last paragraph'.


[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread carbon

Thanks, but that didn't work.
what does the .replaceWith($(this).htlm() do?
shouldn't we use something like 'remove' instead?


On Mar 9, 10:37 am, comslash.com comsl...@gmail.com wrote:
 Try this.

 $('articlep:last').replaceWith($(this).html());

 On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:

  is it possible to use jQuery to strip a tag from a 'div' ?

  example:

  article
  phello world/p
  plast paragraph/p
  /article

  I would like strip the p tags from 'last paragraph'.


[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread Karl Swedberg
Do you just want to remove the p and /p tags? Or do you want to  
remove the paragraph along with along with all of its contents? If the  
latter, then, yes, use ('article  p:last').remove();


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Mar 8, 2009, at 7:44 PM, carbon wrote:



Thanks, but that didn't work.
what does the .replaceWith($(this).htlm() do?
shouldn't we use something like 'remove' instead?


On Mar 9, 10:37 am, comslash.com comsl...@gmail.com wrote:

Try this.

$('articlep:last').replaceWith($(this).html());

On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:


is it possible to use jQuery to strip a tag from a 'div' ?



example:



article
phello world/p
plast paragraph/p
/article



I would like strip the p tags from 'last paragraph'.




[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread carbon

just the tags p, leaving the content 'last paragraph'.


On Mar 9, 10:50 am, Karl Swedberg k...@englishrules.com wrote:
 Do you just want to remove the p and /p tags? Or do you want to  
 remove the paragraph along with along with all of its contents? If the  
 latter, then, yes, use ('article  p:last').remove();

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On Mar 8, 2009, at 7:44 PM, carbon wrote:



  Thanks, but that didn't work.
  what does the .replaceWith($(this).htlm() do?
  shouldn't we use something like 'remove' instead?

  On Mar 9, 10:37 am, comslash.com comsl...@gmail.com wrote:
  Try this.

  $('articlep:last').replaceWith($(this).html());

  On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:

  is it possible to use jQuery to strip a tag from a 'div' ?

  example:

  article
  phello world/p
  plast paragraph/p
  /article

  I would like strip the p tags from 'last paragraph'.


[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread comslash.com

Try this ...

I did some testing and it seems that the $(this) was not selecting
correctly as before and the :last was selecting only the last p tag on
the page not every the last p tag in each article

$('articlep:last-child').each(function(){
 $(this).replaceWith($(this).html());
});

Explination ...

// selecting the last p tag in each article
$('articlep:last-child')

// for each of these p tags do ...
.each(function(){

// the current object
 $(this)

// replace the p tag with what ever is inside of the p tag including
other html tags (ie strong)
.replaceWith($(this).html());

// end the for each and selection
});


On Mar 8, 7:55 pm, carbon carbon.ca...@gmail.com wrote:
 just the tags p, leaving the content 'last paragraph'.

 On Mar 9, 10:50 am, Karl Swedberg k...@englishrules.com wrote:

  Do you just want to remove the p and /p tags? Or do you want to  
  remove the paragraph along with along with all of its contents? If the  
  latter, then, yes, use ('article  p:last').remove();

  --Karl

  
  Karl Swedbergwww.englishrules.comwww.learningjquery.com

  On Mar 8, 2009, at 7:44 PM, carbon wrote:

   Thanks, but that didn't work.
   what does the .replaceWith($(this).htlm() do?
   shouldn't we use something like 'remove' instead?

   On Mar 9, 10:37 am, comslash.com comsl...@gmail.com wrote:
   Try this.

   $('articlep:last').replaceWith($(this).html());

   On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:

   is it possible to use jQuery to strip a tag from a 'div' ?

   example:

   article
   phello world/p
   plast paragraph/p
   /article

   I would like strip the p tags from 'last paragraph'.


[jQuery] Re: Stripping last html tag within an area.

2009-03-08 Thread carbon

thats perfect! thanks comslash!

On Mar 9, 11:29 am, comslash.com comsl...@gmail.com wrote:
 Try this ...

 I did some testing and it seems that the $(this) was not selecting
 correctly as before and the :last was selecting only the last p tag on
 the page not every the last p tag in each article

 $('articlep:last-child').each(function(){
      $(this).replaceWith($(this).html());

 });

 Explination ...

 // selecting the last p tag in each article
 $('articlep:last-child')

 // for each of these p tags do ...
 .each(function(){

 // the current object
  $(this)

 // replace the p tag with what ever is inside of the p tag including
 other html tags (ie strong)
 .replaceWith($(this).html());

 // end the for each and selection

 });

 On Mar 8, 7:55 pm, carbon carbon.ca...@gmail.com wrote:

  just the tags p, leaving the content 'last paragraph'.

  On Mar 9, 10:50 am, Karl Swedberg k...@englishrules.com wrote:

   Do you just want to remove the p and /p tags? Or do you want to  
   remove the paragraph along with along with all of its contents? If the  
   latter, then, yes, use ('article  p:last').remove();

   --Karl

   
   Karl Swedbergwww.englishrules.comwww.learningjquery.com

   On Mar 8, 2009, at 7:44 PM, carbon wrote:

Thanks, but that didn't work.
what does the .replaceWith($(this).htlm() do?
shouldn't we use something like 'remove' instead?

On Mar 9, 10:37 am, comslash.com comsl...@gmail.com wrote:
Try this.

$('articlep:last').replaceWith($(this).html());

On Mar 8, 7:22 pm, carbon carbon.ca...@gmail.com wrote:

is it possible to use jQuery to strip a tag from a 'div' ?

example:

article
phello world/p
plast paragraph/p
/article

I would like strip the p tags from 'last paragraph'.