[jQuery] .hide and .show div's
Hello, Could you help me please. I have a list of hotel which I .hide and .show div's to show more or less info. so i have div class=Hide-BAT1 ... to div class=Hide-Bat55 … when the user press a button I use the code var Hcode = $(this).attr(custom); $('div.Hide-' + Hcode).toggle(); but when the page loads how do I hide this div automatically ? I have used for (i = 0; i = 70; i++) { $(div.Hide-BAT + i).hide(); } But its slow and probably not the best way to do it ? Hope you can help and this makes sense. Regards David
Re: [jQuery] .hide and .show div's
Look at jquerys find functions Sent from my iPhone On 11 Nov 2009, at 12:36, David pr davidpric...@gmail.com wrote: Hello, Could you help me please. I have a list of hotel which I .hide and .show div's to show more or less info. so i have div class=Hide-BAT1 ... to div class=Hide-Bat55 … when the user press a button I use the code var Hcode = $(this).attr(custom); $('div.Hide-' + Hcode).toggle(); but when the page loads how do I hide this div automatically ? I have used for (i = 0; i = 70; i++) { $(div.Hide-BAT + i).hide(); } But its slow and probably not the best way to do it ? Hope you can help and this makes sense. Regards David
Re: [jQuery] .hide and .show div's
$( function() { $(div[class=hide-BAT$].hide(); }); I haven't tested this, but it should work. If not, verify the selector. Not sure why you are giving a unique classname to all these elements. If you need it, why not use the I'd attribute? Regards, Joe On Nov 11, 2009 8:17 AM, David pr davidpric...@gmail.com wrote: Hello, Could you help me please. I have a list of hotel which I .hide and .show div's to show more or less info. so i have div class=Hide-BAT1 ... to div class=Hide-Bat55 … when the user press a button I use the code var Hcode = $(this).attr(custom); $('div.Hide-' + Hcode).toggle(); but when the page loads how do I hide this div automatically ? I have used for (i = 0; i = 70; i++) { $(div.Hide-BAT + i).hide(); } But its slow and probably not the best way to do it ? Hope you can help and this makes sense. Regards David
Re: [jQuery] .hide and .show div's
Oops. got the selector wrong. It should be: $( function() { $(div[class^=hide-BAT].hide(); }); Joe On Wed, Nov 11, 2009 at 8:38 AM, Joe Moore joe.lynn.mo...@gmail.com wrote: $( function() { $(div[class=hide-BAT$].hide(); }); I haven't tested this, but it should work. If not, verify the selector. Not sure why you are giving a unique classname to all these elements. If you need it, why not use the I'd attribute? Regards, Joe On Nov 11, 2009 8:17 AM, David pr davidpric...@gmail.com wrote: Hello, Could you help me please. I have a list of hotel which I .hide and .show div's to show more or less info. so i have div class=Hide-BAT1 ... to div class=Hide-Bat55 … when the user press a button I use the code var Hcode = $(this).attr(custom); $('div.Hide-' + Hcode).toggle(); but when the page loads how do I hide this div automatically ? I have used for (i = 0; i = 70; i++) { $(div.Hide-BAT + i).hide(); } But its slow and probably not the best way to do it ? Hope you can help and this makes sense. Regards David