suzie Posted August 18, 2010 Share Posted August 18, 2010 Dear Friends,am using in my script animatedcollapse function, for 4 items listed one near each other (display: inline).each time the visitor of the site click on an item , a text under will be shown, and if he clicks on another item, the last text will be collapsed and the other text will be shown...now in case for the visitor to know on which item he is I need that ontoggle, that the color of the selected item change color..Is this Possible???I have them in this way:--------------------------------------------------1st Item | 2nd item | 3rd item | 4th item |-------------------------------------------------- and the text will be shown here | and the text will | and the text will be shown here |-------------------------------------------------- and here is the function:<script type=text/javascript>animatedcollapse.addDiv('3', 'fade=0,speed=400,group=cat')animatedcollapse.addDiv('4', 'fade=0,speed=400,group=cat')animatedcollapse.addDiv('5', 'fade=0,speed=400,group=cat')animatedcollapse.addDiv('6', 'fade=0,speed=400,group=cat')animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted //$: Access to jQuery //divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID //state: "block" or "none", depending on state}animatedcollapse.init()</script> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 18, 2010 Share Posted August 18, 2010 It looks like you can use the state to figure out if the element is expanded or collapsed (state will be "block" if it's expanded), and you can use the divobj to reference the element to change the style. You'll probably also want to change the styles of the collapsed divs to make sure they're not highlighted. Link to comment Share on other sites More sharing options...
suzie Posted August 19, 2010 Author Share Posted August 19, 2010 thanks, I know how to use the divobj and the state, but how I can I change the Div Class...If I enter in the Javascript functionif (divobj.id == 3){how to say that change the class of a Div, is it possible from here....the class "more-titles", when selected it should take "more-titles-select"}Thank you Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2010 Share Posted August 19, 2010 The element has a setAttribute method that you can use, you should set both class and className to make sure it works across browsers. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.