kingsinnersoul Posted June 22, 2013 Share Posted June 22, 2013 (edited) Hello, I am trying to apply css code to the first level categories only. But when I add css to [/size] #categories_block_left li it applies it to all the categories. Thanks Edited June 24, 2013 by kingsinnersoul (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 22, 2013 Share Posted June 22, 2013 You would need the element or class which is above the first ul, then specify {parent-selector} > ul > li. Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 24, 2013 Author Share Posted June 24, 2013 Thanks, how can I apply css to it only if it is closed? Link to comment Share on other sites More sharing options...
vekia Posted June 24, 2013 Share Posted June 24, 2013 what you mean by "closed" ? Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 24, 2013 Author Share Posted June 24, 2013 So each category which has children has a [+] sign box on the right side which is nested inside a <span> tag. This sign is span has the class grower. But when the category is not expanded the span has additional class "CLOSE", and when it is expanded is has the class "OPEN". I wanted to apply css to the li itself if the nested span tag has one of the tags. Thanks Link to comment Share on other sites More sharing options...
vekia Posted June 24, 2013 Share Posted June 24, 2013 {parent-selector} > ul > li.closed {parent-selector} > ul > li.open etc. Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 24, 2013 Author Share Posted June 24, 2013 that applies the css only to the [+] or [-] button. I tried to add the css code in javascript, but it did not work for me. Any idea where that <span> tag is added to the categories block module? I cannot see it in the tpl file. I thought that I could add some code to the open/close js portions where it loads the exapnd portion to add/remove css from the parent. Link to comment Share on other sites More sharing options...
kingsinnersoul Posted June 24, 2013 Author Share Posted June 24, 2013 I did it by going to treeManagement.js and editing toggleBranch to have extra two lines: //animate the closing or opening of the branch (ul jQueryElement) function toggleBranch(jQueryElement, noAnimation) { if(jQueryElement.hasClass('OPEN')) { closeBranch(jQueryElement, noAnimation); $(jQueryElement.parent()).addClass('CLOSE').removeClass('OPEN'); } else { openBranch(jQueryElement, noAnimation); $(jQueryElement.parent()).addClass('OPEN').removeClass('CLOSE'); } } and then added $('.block_content >ul > li').addClass('CLOSE').removeClass('OPEN'); as the first line inside $(document).ready(function () { and then I added css code for .block_content >ul > li.CLOSE Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now