Thanks Ben i'm givin it a try.
;-))
GC

On Sep 19, 5:29 pm, "Benjamin Sterling"
<[EMAIL PROTECTED]> wrote:
> My bad, change pStart to 5 to get 5 P
>
> On 9/19/07, Benjamin Sterling <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Just tested that and it works like a charm, hope it helps.
>
> > On 9/19/07, Benjamin Sterling <[EMAIL PROTECTED] > wrote:
>
> > > Gian,
> > > You can actually do more with less using the slice method, something
> > > like below should do you:
>
> > > $(function(){
> > > var pStart = 4;
> > > $("#newswrapper p").slice(pStart).hide();
>
> > > $("a#sa").toggle(
> > > function(){
> > > $("#newswrapper p").slice(pStart).show();
> > > },
> > > function(){
> > > $("#newswrapper p").slice(pStart).hide();
> > > }
> > > );
> > > });
>
> > > This is untested, but should work.
>
> > > On 9/19/07, GianCarlo Mingati <[EMAIL PROTECTED]> wrote:
>
> > > > Hi guys.
> > > > I have a DIV with let's say 10 paragraph.
> > > > I want to show just 5 paragraph on page load and let the users "view
> > > > more" (news) by clicking a button, or a link.
> > > > I ended up with these lines in 10 seconds but i can't made them
> > > > shorter. Can you?
>
> > > > pStart sets the nuber of elements to be showed.
> > > > pTotal is the total amount of Ps
>
> > > > when i click a#sa i toggle between two functions, one checks if the
> > > > number of paragraph is less then 5 and show them. the other function
> > > > in toggle do the rest.
>
> > > > Can you shorten these lines please (if you got time) and show me a
> > > > better way to do that?
> > > > Thanks in advance, hope i've been clear enough.
> > > > GC
>
> > > > $(function(){
> > > > var pStart = 4 //vuol dire 5 paragrafi, 0 incluso;
> > > > var pTotal = $("#newswrapper p").length;
> > > > doMore(pStart);
> > > > $("a#sa").toggle(function(){
> > > >                 doMore(pTotal);
> > > >                 },function(){
> > > >         doLess(pStart);
> > > > });
> > > > function doMore(myparam){
> > > >         $("#newswrapper p").each(function(i) {
> > > >                 if (i <= myparam){
> > > >                         $(this).show("fast");
> > > >                 }
> > > >         });
> > > > }
> > > > function doLess(myparam){
> > > >         $("#newswrapper p").each(function(i) {
> > > >                 if (i > myparam){
> > > >                         $(this).hide("fast");
> > > >                 }
> > > >         });
> > > > }
> > > > });
>
> > > --
> > > Benjamin Sterling
> > >http://www.KenzoMedia.com
> > >http://www.KenzoHosting.com
>
> > --
> > Benjamin Sterling
> >http://www.KenzoMedia.com
> >http://www.KenzoHosting.com
>
> --
> Benjamin Sterlinghttp://www.KenzoMedia.comhttp://www.KenzoHosting.com

Reply via email to