Re: [jQuery] Selecting PARENT DIV
$(div.name).click(function(){ $(this).next().toogle( function(){ $(this).show(); }, function(){ $(this).hide(); } ); }); On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: How could I get the ID from a parent div of my element? I think that will be the shortest path to do what i need, as described bellow: Example: div id=1 class=company div class=nameSome Company/div div class=moreinfoSomething about the company/div /div div id=2 class=company div class=nameOther Company/div div class=moreinfoSomething about the other company/div /div I'm trying to do a company list of my city. The .moreinfo will be showed when clicked into Some Company or Other Company, obviously showing just more info of the clicked company. Thanks a lot! Villa, Gustavo. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Selecting PARENT DIV
Hi Gustavo, this would be more semantic: div id=1 class=company h2 class=nameSome Company/h2 div class=moreinfo pSomething about the company/p /div /div div id=2 class=company h2 class=nameOther Company/h2 div class=moreinfo pSomething about the other company/p /div /div Also, ids shouldn't start with a number. I'd use this function, but I'm sure other people could do better - I'm more of a CSS person! function toggleMenuItems(theElement, selectedClassName){ $(theElement).click(function() { theParent = this.parentNode; toggleClass(this, selectedClassName); toggleSibling(this);// the elements in this container that aren't this click handler return false; }); } function toggleSibling(theElement){ var theSiblings = $(theElement).siblings().not(theElement); $(theSiblings).toggle(slow); } and this in your document.ready function: toggleMenuItems(div.company h2, closed); with .closed { } being any CSS you might want to add. Thanks, Dan. On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: How could I get the ID from a parent div of my element? I think that will be the shortest path to do what i need, as described bellow: Example: div id=1 class=company div class=nameSome Company/div div class=moreinfoSomething about the company/div /div div id=2 class=company div class=nameOther Company/div div class=moreinfoSomething about the other company/div /div I'm trying to do a company list of my city. The .moreinfo will be showed when clicked into Some Company or Other Company, obviously showing just more info of the clicked company. Thanks a lot! Villa, Gustavo. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Selecting PARENT DIV
Oh, I forgot - remove the toggleClass call. I used it to change the formatting of my 'company names' when they were open or closed. You could write your own function to do that, of course! On 3/5/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi Gustavo, this would be more semantic: div id=1 class=company h2 class=nameSome Company/h2 div class=moreinfo pSomething about the company/p /div /div div id=2 class=company h2 class=nameOther Company/h2 div class=moreinfo pSomething about the other company/p /div /div Also, ids shouldn't start with a number. I'd use this function, but I'm sure other people could do better - I'm more of a CSS person! function toggleMenuItems(theElement, selectedClassName){ $(theElement).click(function() { theParent = this.parentNode; toggleClass(this, selectedClassName); toggleSibling(this);// the elements in this container that aren't this click handler return false; }); } function toggleSibling(theElement){ var theSiblings = $(theElement).siblings().not(theElement); $(theSiblings).toggle(slow); } and this in your document.ready function: toggleMenuItems(div.company h2, closed); with .closed { } being any CSS you might want to add. Thanks, Dan. On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: How could I get the ID from a parent div of my element? I think that will be the shortest path to do what i need, as described bellow: Example: div id=1 class=company div class=nameSome Company/div div class=moreinfoSomething about the company/div /div div id=2 class=company div class=nameOther Company/div div class=moreinfoSomething about the other company/div /div I'm trying to do a company list of my city. The .moreinfo will be showed when clicked into Some Company or Other Company, obviously showing just more info of the clicked company. Thanks a lot! Villa, Gustavo. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Selecting PARENT DIV
Thanks for reply Dan and Leonardo! I will try your suggestions! Brazilian Huges for you! Villa, Gustavo. -- SimDigital Visite nosso site: www.simdigital.com.br (15) 3012.7200 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Selecting PARENT DIV
Dan, another question: Why did you typed: "Also, ids shouldn't start with a number." What is the right standard? Gustavo Villa. Dan Eastwell escreveu: Hi Gustavo, this would be more semantic: div id="1" class="company" h2 class="name"Some Company/h2 div class="moreinfo" pSomething about the company/p /div /div div id="2" class="company" h2 class="name"Other Company/h2 div class="moreinfo" pSomething about the other company/p /div /div Also, ids shouldn't start with a number. I'd use this function, but I'm sure other people could do better - I'm more of a CSS person! function toggleMenuItems(theElement, selectedClassName){ $(theElement).click(function() { theParent = this.parentNode; toggleClass(this, selectedClassName); toggleSibling(this); // the elements in this container that aren't this click handler return false; }); } function toggleSibling(theElement){ var theSiblings = $(theElement).siblings().not(theElement); $(theSiblings).toggle("slow"); } and this in your document.ready function: toggleMenuItems("div.company h2", "closed"); with .closed { } being any CSS you might want to add. Thanks, Dan. On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: How could I get the ID from a parent div of my element? I think that will be the shortest path to do what i need, as described bellow: Example: div id="1" class="company" div class="name"Some Company/div div class="moreinfo"Something about the company/div /div div id="2" class="company" div class="name"Other Company/div div class="moreinfo"Something about the other company/div /div I'm trying to do a company list of my city. The ".moreinfo" will be showed when clicked into "Some Company" or "Other Company", obviously showing just more info of the clicked company. Thanks a lot! Villa, Gustavo. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Selecting PARENT DIV
Don't thank us until it works! Let me know how you go, I'd be interested. IDs should just start with a letter - given that you can only have one id on any page, it would make sense to name your IDs so they are useful to you in the future, such as div id=company-02 class=company You might not need an id at all, unless it's coming from the back-end, as you can choose the e.g. 4th div.company with jquery. Dan. On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: Dan, another question: Why did you typed: Also, ids shouldn't start with a number. What is the right standard? Gustavo Villa. Dan Eastwell escreveu: Hi Gustavo, this would be more semantic: div id=1 class=company h2 class=nameSome Company/h2 div class=moreinfo pSomething about the company/p /div /div div id=2 class=company h2 class=nameOther Company/h2 div class=moreinfo pSomething about the other company/p /div /div Also, ids shouldn't start with a number. I'd use this function, but I'm sure other people could do better - I'm more of a CSS person! function toggleMenuItems(theElement, selectedClassName){ $(theElement).click(function() { theParent = this.parentNode; toggleClass(this, selectedClassName); toggleSibling(this); // the elements in this container that aren't this click handler return false; }); } function toggleSibling(theElement){ var theSiblings = $(theElement).siblings().not(theElement); $(theSiblings).toggle(slow); } and this in your document.ready function: toggleMenuItems(div.company h2, closed); with .closed { } being any CSS you might want to add. Thanks, Dan. On 3/5/07, JQuery - SimDigital [EMAIL PROTECTED] wrote: How could I get the ID from a parent div of my element? I think that will be the shortest path to do what i need, as described bellow: Example: div id=1 class=company div class=nameSome Company/div div class=moreinfoSomething about the company/div /div div id=2 class=company div class=nameOther Company/div div class=moreinfoSomething about the other company/div /div I'm trying to do a company list of my city. The .moreinfo will be showed when clicked into Some Company or Other Company, obviously showing just more info of the clicked company. Thanks a lot! Villa, Gustavo. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/