[jQuery] Highlighting the first element in multiple DIVS
Hello, I am looking for some guidance on how to achieve a simple objective. I have multiple DIV elements on a page, and within each DIV there are 4 A elements. Within each A there is an IMG. My goal is to apply a class to each of these IMG upon rendering the page. div class=description a class=colour href=#img class=icon src=/images/icons/ snowwhite.png alt=Snow White/a a class=colour href=#img class=icon src=/images/icons/ deepcream.png alt=Deep Cream/a a class=colour href=#img class=icon src=/images/icons/ mistygrey.png alt=Misty Grey/a a class=colour href=#img class=icon src=/images/icons/ paleivory.png alt=Pale Ivory/a /div I have tried using $(div.description a.colour:first-child img.icon).addClass(icon_selected); but that does not work. Please help as I am going round in circles. Thank you. Best regards, Martin
[jQuery] Re: Highlighting the first element in multiple DIVS
Hi, I am looking for some guidance on how to achieve a simple objective. I have multiple DIV elements on a page, and within each DIV there are 4 A elements. Within each A there is an IMG. My goal is to apply a class to each of these IMG upon rendering the page. the above post has a typo. The bit that says My goal is to apply a class to each of these IMG upon rendering the page should read as My goal is to apply a class to the first IMG within each of these DIV upon rendering the page. To add, there could be several different classes of A within each DIV, so the operation would have to then be repeated within each DIV and within each A class. I hope this makes sense. Best regards, Martin
[jQuery] Re: Highlighting the first element in multiple DIVS
Hi Mauricio, $('.description a:first-child img').addClass('icon_selected'); the complete not-working example can be found here: http://0.latest.gentlecolours.appspot.com/albums?album_name=Leigh_on_sea Two things come to my mind: the statement is placed in the wrong place or it clashes with some other JS on the page (Thickbox and Google Checkout). Best regards, Martin
[jQuery] Re: Highlighting the first element in multiple DIVS
$('.description img:eq(0)').addClass('icon_selected') // add class to the 1st image element whitin div.description Now it selects the first image of the first div only. I have updated the test website with your change. Martin
[jQuery] Re: IE ignores event load()
Hi, Is your XHTML mark-up valid? (assuming you're writing XHTML) That may affect the events behaviour. I am using XHTML 1.1, the W3 validator gives it all green. Took me a while to achieve that. I will try the site on IE7 to see if it has the same problems. Maybe it is the IE6 fault. Martin
[jQuery] Re: IE ignores event load()
RESOLVED: $(window).load(function() { $(img.thumb:hidden).addClass(visible); //catch all for all hidden elements left behind }); $(document).ready(function() { $(img.thumb).load(function() { $(this).addClass(visible); //for the majority of thumbnails, this will happen here });
[jQuery] IE ignores event load()
Hi, please could somebody tell me how to improve the following code: $(document).ready(function() { $(img.thumb).load(function() { $(this).addClass(visible); }); }); The idea is that an image needs to be displayed only when it has fully loaded. Prior to that the background of the div is displayed as the image is set to hidden. FF and Opera are fine with this, but IE6 consistently fails to unhide some images. I guess the .load() function is called too late for some of them, but not sure how to improve the situation. Thank you! Martin
[jQuery] Re: IE ignores event load()
Hi MorningZ, $(window).load(function() { $(img.thumb).addClass(visible); }); will do what you are after thank you for your response. The problem with this one is that it will not show a single image until the whole lot has loaded - and that can be 20 or so seconds if the connection is slow. And then it will show them all at once. I am starting to think that I will have to use an array that contains all image URLs, then artificially create images one by one, and define the load() event on each. This is something I am not very keen on doing because I am rendering the HTML by using a django template. Another potential idea is that I can create a loop once the DOM is ready and convert invisible objects to visible until none are left. But at the same time this could lead to CPU spikes and this is something I am trying to avoid as well. Best regards, Martin
[jQuery] Re: File Upload
Hi, you can also try www.swfupload.org, it is fully configurable. On Aug 28, 5:05 am, Karl Rudd [EMAIL PROTECTED] wrote: The file input doesn't style very well, at least on all browser. Have a look here: http://www.quirksmode.org/dom/inputfile.html You can kind of fake it, that is you hide the actual input and do some tricks with JavaScript. There's a jQuery plugin that does this by the looks of it: http://www.appelsiini.net/projects/filestyle (found via a Google search for css file input jquery) Karl Rudd On Thu, Aug 28, 2008 at 11:46 AM, shapper [EMAIL PROTECTED] wrote: Hi, Does anyone knows how to style and input of type file with JQuery? I want to use an image as the button or maybe a simple normal input styled with CSS. I also want to style the input where the path is ... I want it to have a grey background and no border. Any idea of how to accomplish this? Thanks, Miguel