[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Joel Birch


How about:

var first_paragraphs = $('#book div.page p:first');

Joel.

On 06/06/2007, at 12:34 AM, Sebastián V. Würtz wrote:


How i get the first p of each div page inside the id book?

This not work
$('#book .page').each(function(index) {
 var first_paragraph = $(this +  p).eq(0);

div id=book
 div class=page
  h1xxx/h1
  p/p
  pdd/p
 /div
 div class=page
  h1asdasdas/h1
  p/p
  p/p
 /div
 div class=page
  h1222/h1
  p/p
 /div

/div


thx

Estoy utilizando la versión gratuita de SPAMfighter para usuarios  
privados.

Ha eliminado 2470 correos spam hasta la fecha.
Los abonados no tienen este mensaje en sus correos.
¡Pruebe SPAMfighter gratis ya!




[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Sebastián V . Würtz


Right. but i need all the first paragraph of each page, to execute an 
each function for each one :)


Ok. this is what i looking, put in cap each letter of only the first 
paragraph of each sign, like a combination of fancy drop caps part 1 and 
fancy drop caps part 2


http://www.learningjquery.com/2006/10/fancy-drop-cap-part-1
http://www.learningjquery.com/2006/10/fancy-drop-cap-part-2

$(document).ready(function(){
 swap_letter();
});

function swap_letter() {
 var parag = $('.firma p:first');- Only get the fisrt
 parag.each(function(index) {
  var first_paragraph = this;
  if (!first_paragraph) return false;
  var node = first_paragraph;
  while (node.childNodes.length) {
node = node.firstChild;
  }

  var text = node.nodeValue;
  var first_letter = text.substr(0,1);
  var match = /[a-zA-Z]/.test(first_letter);
  if ( match ) {
node.nodeValue = text.slice(1);
$('img /')
 .attr('src','assets/alphabet/' + first_letter.toLowerCase() + '.gif')
 .attr('alt',first_letter)
 .addClass('fancy-letter')
 .prependTo( first_paragraph );
  }
 });
}





- Original Message - 
From: Joel Birch [EMAIL PROTECTED]

To: jquery-en@googlegroups.com
Sent: Tuesday, June 05, 2007 11:40 AM
Subject: [jQuery] Re: Problem getting first paragraph



How about:

var first_paragraphs = $('#book div.page p:first');

Joel.

On 06/06/2007, at 12:34 AM, Sebastián V. Würtz wrote:


How i get the first p of each div page inside the id book?

This not work
$('#book .page').each(function(index) {
 var first_paragraph = $(this +  p).eq(0);

div id=book
 div class=page
  h1xxx/h1
  p/p
  pdd/p
 /div
 div class=page
  h1asdasdas/h1
  p/p
  p/p
 /div
 div class=page
  h1222/h1
  p/p
 /div

/div


thx

Estoy utilizando la versión gratuita de SPAMfighter para usuarios 
privados.

Ha eliminado 2470 correos spam hasta la fecha.
Los abonados no tienen este mensaje en sus correos.
¡Pruebe SPAMfighter gratis ya!



__ NOD32 2309 (20070605) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com



--
Estoy usando la versión gratuita de SPAMfighter para usuarios privados.
Ha eliminado 2470 correos spam hasta la fecha.
Los usuarios de pago no tienen este mensaje en sus correos.
Obtenga SPAMfighter gratis aquí: http://www.spamfighter.com/les




[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Joel Birch


On 06/06/2007, at 12:48 AM, Sebastián V. Würtz wrote:
Right. but i need all the first paragraph of each page, to  
execute an each function for each one :)


Sorry if I am misunderstanding, but as far as I can tell this should  
work:


 $('#book div.page p:first').each(function() {
/*do stuff with each first paragraph found within each .page div*/
});

For example, try this to test if we are getting the elements you  
require:


$(document).ready(function() {
$('#book div.page p:first').each(function() {
this.css({'background-color':'yellow'});
});
)};

Good luck.

Joel.

[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Joel Birch


On 06/06/2007, at 12:57 AM, Joel Birch wrote:


On 06/06/2007, at 12:48 AM, Sebastián V. Würtz wrote:
Right. but i need all the first paragraph of each page, to  
execute an each function for each one :)


Sorry if I am misunderstanding, but as far as I can tell this  
should work:


 $('#book div.page p:first').each(function() {
/*do stuff with each first paragraph found within each .page div*/
});

For example, try this to test if we are getting the elements you  
require:


$(document).ready(function() {
$('#book div.page p:first').each(function() {
this.css({'background-color':'yellow'});
});
)};

Good luck.

Joel.

Scratch that. For starters I forgot to wrap 'this' in $(). Also, it  
only seems to get the the first para of the first .page element.


I'll try again.

[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Sebastián V . Würtz


ill notice, but still can make it work, im checking the html generated by 
the php, or make a new clean code for test.


:)

thx
- Original Message - 
From: Joel Birch [EMAIL PROTECTED]

To: jquery-en@googlegroups.com
Sent: Tuesday, June 05, 2007 12:02 PM
Subject: [jQuery] Re: Problem getting first paragraph



On 06/06/2007, at 12:57 AM, Joel Birch wrote:


On 06/06/2007, at 12:48 AM, Sebastián V. Würtz wrote:
Right. but i need all the first paragraph of each page, to  execute 
an each function for each one :)


Sorry if I am misunderstanding, but as far as I can tell this  should 
work:


 $('#book div.page p:first').each(function() {
/*do stuff with each first paragraph found within each .page div*/
});

For example, try this to test if we are getting the elements you  require:

$(document).ready(function() {
$('#book div.page p:first').each(function() {
this.css({'background-color':'yellow'});
});
)};

Good luck.

Joel.


Scratch that. For starters I forgot to wrap 'this' in $(). Also, it
only seems to get the the first para of the first .page element.

I'll try again.
__ NOD32 2309 (20070605) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com



--
Estoy usando la versión gratuita de SPAMfighter para usuarios privados.
Ha eliminado 2470 correos spam hasta la fecha.
Los usuarios de pago no tienen este mensaje en sus correos.
Obtenga SPAMfighter gratis aquí: http://www.spamfighter.com/les




[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Michael Price


Try this.

Given the following HTML:
div id=book
div class=page
pParagraph one, page one/p

pParagraph two, page one/p

pParagraph three, page one/p
/div
div class=page
pParagraph one, page two/p

pParagraph two, page two/p

pParagraph three, page two/p
/div
div class=page
pParagraph one, page three/p

pParagraph two, page three/p

pParagraph three, page three/p
/div
div class=page
pParagraph one, page four/p

pParagraph two, page four/p

pParagraph three, page four/p
/div
div class=page
pParagraph one, page five/p

pParagraph two, page five/p

pParagraph three, page five/p
/div
/div

The following jQuery code should do the trick:
$(#book .page).each(function() {
$(p:first,this).css(backgroundColor,yellow);
});

The result of five minutes messing about, it seems to do what you're 
after but I'm sure it can be improved upon.


Regards,
Michael Price



[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Joel Birch


On 06/06/2007, at 1:13 AM, Michael Price wrote:

The following jQuery code should do the trick:
$(#book .page).each(function() {
$(p:first,this).css(backgroundColor,yellow);
});


Thanks Michael., that should do it. So Sebastián's solution could  
look like:


$(#book .page).each(function(){
$(p:first,this).each(function(){
/* do stuff with the first paragraph found within each .page 
div */
});
});

I'm sure this can be reduced even further. Maybe something like:

$('#book .page').find('p:first').each(function(){
/* do stuff ... */
});

or even:

$('p:first','#book .page').each(function(){
/* do stuff ... */
});

Joel.

[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Joel Birch


On 06/06/2007, at 1:30 AM, Joel Birch wrote:

$('p:first','#book .page').each(function(){
/* do stuff ... */
});


Actually, :first may only ever return one element, maybe this works  
better:


$('p:eq(0)','#book .page').each(function(){
/* do stuff ... */
});

Sorry for the hit-and-miss postings. I'll stop now.

Joel.


[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread sebastianw wurtz
Thx guys both solutions work very good and my guestbook look perfect.

The next i want to do is study to resolve howto implent something like a 
pagination withount next page, only with the mousewheel and ajax callback

But, this is other story ;)

thx again

- Mensaje original 
De: Joel Birch [EMAIL PROTECTED]
Para: jquery-en@googlegroups.com
Enviado: martes 5 de junio de 2007, 12:34:18
Asunto: [jQuery] Re: Problem getting first paragraph


On 06/06/2007, at 1:30 AM, Joel Birch wrote:
 $('p:first','#book .page').each(function(){
 /* do stuff ... */
 });

Actually, :first may only ever return one element, maybe this works  
better:

$('p:eq(0)','#book .page').each(function(){
/* do stuff ... */
});

Sorry for the hit-and-miss postings. I'll stop now.

Joel.











__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 


[jQuery] Re: Problem getting first paragraph

2007-06-05 Thread Brandon Aaron

Here is the mouse wheel plugin to help get you started with that. :)
http://jquery.com/plugins/project/mousewheel

--
Brandon Aaron

On 6/5/07, sebastianw wurtz [EMAIL PROTECTED] wrote:


Thx guys both solutions work very good and my guestbook look perfect.

The next i want to do is study to resolve howto implent something like a
pagination withount next page, only with the mousewheel and ajax callback

But, this is other story ;)

thx again

- Mensaje original 
De: Joel Birch [EMAIL PROTECTED]
Para: jquery-en@googlegroups.com
Enviado: martes 5 de junio de 2007, 12:34:18
Asunto: [jQuery] Re: Problem getting first paragraph


On 06/06/2007, at 1:30 AM, Joel Birch wrote:
 $('p:first','#book .page').each(function(){
 /* do stuff ... */
 });

Actually, :first may only ever return one element, maybe this works
better:

$('p:eq(0)','#book .page').each(function(){
/* do stuff ... */
});

Sorry for the hit-and-miss postings. I'll stop now.

Joel.


--
*Preguntá. Respondé. Descubrí.*
Todo lo que querías saber, y lo que ni imaginabas,
está en *Yahoo! Respuestas* (Beta).
*Probalo ya! http://ar.answers.yahoo.com*