Results 1 to 5 of 5

Thread: Animated Collapsible DIV v2.2 - how to change text on links?

  1. #1
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Animated Collapsible DIV v2.2 - how to change text on links?

    Animated Collapsible DIV v2.2

    Script URL (on DD): http://www.dynamicdrive.com/dynamici...edcollapse.htm and http://www.dynamicdrive.com/dynamici...suppliment.htm

    The second link shows a way of changing two buttons so that the text toggles when the div is toggled. My question is, how can this be achieved with a text link? (I'm using a link to toggle the div, not an image.)

    Thanks in advance.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Are you talking about regular text links that toggle a DIV, in which there is also an image toggler that should be updated based on the DIV's state? If so this is already the case when you follow the instructions on the supplementary page. For example, the demo near the bottom here reflects this.
    DD Admin

  3. #3
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi.

    Thanks for your reply. I just want regular text links - no images. But the text should behave like the images on the page you're referring to, so that when clicking the "Expand" link to toggle the div the text link changes to "Collapse".
    I can't figure out how to change the script to do exactly that.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    The process is exactly the same actually, except instead of updating the toggler's ".src" property, you'd update its ".innerHTML" property instead. For example:

    Code:
    animatedcollapse.ontoggle=function($, divobj, state){
    	if (document.getElementById(divobj.id+"-toggler"))
    		document.getElementById(divobj.id+"-toggler").innerHTML=(state=="block")? "Collapse" : "Expand"
    }
    HTML:

    Code:
    <a id="jason-toggler" href="javascript:animatedcollapse.toggle('jason')">Toggle</a>
    
    <div id="jason" style="width: 300px; background: #FFFFCC; display:none">
    <b>Content inside DIV!</b><br />
    <b>Note: Fade effect enabled. Height programmically defined. DIV hidden using inline CSS.</b><br />
    </div>
    DD Admin

  5. #5
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Ah, of course. That was the property I was looking for. Works perfectly. Thanks a lot for your help! (How do I mark this thread solved?)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •