Solved

JavaScript Collapse Box  IMG

Posted on 2010-11-23
4
403 Views
Last Modified: 2012-06-27
I am working in Drupal with a collapseable javascript box.  At the moment, We have Text which you click to open and close the box. What we want to do, and are trying to do, is in place of text, we want an image(Button) to be click-able to open and close the box.

I have tried just inserting an image, but when you click the image button, the box collapses and so does the button, and you are unable to open the box again. If after the button i put a single character in this case "X" i can click the image, to close the box, but only the "X" appears on the closed box.

I have attached a screenshot of the button and X, also the code and file of the collapsible.js.

Could somebody help me with this please.

// Turn the legend into a clickable link and wrap the contents of the fieldset
    // in a div for easier animation
    var text = this.innerHTML;
      $(this).empty().append($('<a href="#">'+ text +'</a>').click(function() {
        var fieldset = $(this).parents('fieldset:first')[0];
        // Don't animate multiple times
        if (!fieldset.animating) {
          fieldset.animating = true;
          Drupal.toggleFieldset(fieldset);
        }
        return false;
      }))
      .after($('<div class="fieldset-wrapper"></div>')
      .append(fieldset.children(':not(legend):not(.action)')))
      .addClass('collapse-processed');

Open in new window


 
 
0
Comment
Question by:Jon Imms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
Codebot earned 500 total points
ID: 34203422
Hi
you can use  div or span  and then call function on onclick event of div.
0
 

Author Comment

by:Jon Imms
ID: 34209766
Sorry to ask, but how would i do that ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A big percent of today’s marketing activity is performed through the online environment. The marketing strategies that have existed a decade ago no longer relate to what’s happening today. We’re currently facing a revolutionary era, called the digit…
Six Sigma Control Plans
Starting up a Project

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question