osdir.com
mailing list archive

Subject: [jQuery] Re: Selecting a child of 'this' - msg#00504

List: jQuery

Date: Prev Next Index Thread: Prev Next Index

You can save a reference to the child elements (if they'll not change)
to avoid finding them over and over:

$("#parent").each(function(){
var $child = $(this).find('.child');
var $children = $('.child');

$(this).hover(function(){
$c.show();
},function(){
$children.hide();
});

});

On Mar 4, 2:50 am, schickb <schi...@xxxxxxxxx> wrote:
> I'd like to apply a css effect to a child upon hovering over its
> parent. Both are block level elements. The trick is that there is a
> list of these and I only want to modify one at a time. I've got
> something that works, but it feels a bit ugly:
>
>     $("#parent").hover(
>         function(){
>                 // This is the line in question.
>                 $('#' + this.id + ' .child').show();
>         },
>         function(){
>                 // Hide them all
>                 $('.child').hide();
>         }
>     );
>
> I could use Ids on the children that are derived from their parents,
> but that doesn't seem any cleaner. Is there a better way to handle
> this?

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

[jQuery] Re: what's better?

Well, the second version won't help very much since you are not reusing "myEL" later on On Mar 4, 9:36 am, hcvitto <hcvi...@xxxxxxxxx> wrote: > hi > just needed an advice... > what' s better between this two (if there's any difference at all): > > this: > > $('a[class^=open]').click(function(){ >     ...whatever... > > }); > > or this: > > var myEl = $('a[class^=open]'); > $(myEl).each(function(){ >      $(this).click(function(){ >         ...whatever... >      }); > )}; > > thanks > Vitto

Next Message by Date: click to view message preview

[jQuery] Re: Noob alert - can you help clean up my ticker?

Thanks for the advice and thanks for the links....i'd looked at the hacking at 0300 tutorial yesterday but was a bit fried to take it in. anyway, today I decided to give it another go and have come up with the following. I think it is slightly more 'elegant' but who knows!? Demo: http://www.rees-jenkins.co.uk/weebticker/ Source: http://www.rees-jenkins.co.uk/weebticker/scripts/jquery.weebticker.js Not sure where to take this now...any suggestions welcome :) On 4 Mar, 08:53, "Richard D. Worth" <rdwo...@xxxxxxxxx> wrote: > By the way, great little plugin. I like the demo. > > - Richard > > On Wed, Mar 4, 2009 at 3:52 AM, Richard D. Worth <rdwo...@xxxxxxxxx> wrote: > > > > > On Wed, Mar 4, 2009 at 3:44 AM, w33bs...@xxxxxxxxxxxxxx < > > w33bs...@xxxxxxxxxxxxxx> wrote: > > >> I was thinking of using JQuery UI core to build a class to handle > >> this...would this be the way to go? > > > You could do it just as a jQuery plugin, or you could use jQuery UI's > > widget plugin. If you decide to go the jQuery UI route, here's a tutorial to > > get you started: > > >http://youngisrael-stl.org/wordpress/understanding-jquery-ui-widgets-... > > > and here's some documentation: > > >http://wiki.jqueryui.com/Widget-factory > > >http://docs.jquery.com/UI/Developer_Guide > > > If you have any questions, we can help you out on the jQuery UI list: > > >http://groups.google.com/group/jquery-ui > > > - Richard

Previous Message by Thread: click to view message preview

[jQuery] Re: Selecting a child of 'this'

$(this).find(".child").show() On Mar 4, 12:50 am, schickb <schi...@xxxxxxxxx> wrote: > I'd like to apply a css effect to a child upon hovering over its > parent. Both are block level elements. The trick is that there is a > list of these and I only want to modify one at a time. I've got > something that works, but it feels a bit ugly: > >     $("#parent").hover( >         function(){ >                 // This is the line in question. >                 $('#' + this.id + ' .child').show(); >         }, >         function(){ >                 // Hide them all >                 $('.child').hide(); >         } >     ); > > I could use Ids on the children that are derived from their parents, > but that doesn't seem any cleaner. Is there a better way to handle > this?

Next Message by Thread: click to view message preview

[jQuery] I need two progress bars superimposed on one another

Hi, Here is my requirement: I need to have a progress bar which should show me details of the following: Total number of test cases ran, Total number of test cases passed. it should be displayed as shown: |---------------a>---------------------------------- b>----------------------------| 0 20 60 100 here, the entire length of the progress bar will correspond to count of total number of test cases I have, the level till b> from 0 will give me the total number of test cases executed and level till a> from 0 will give me the total number of test cases Passed out of the total number of test cases ran a> can never go beyond b> and b> can never go beyond 100 mark Is this achievable through this wonderful jquery progress bar ...?? Please give me advise :-) ..
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by