I am using Twitter Bootstrap to create collapsible sections of text. The sections are expanded when a +
button is pressed. My html code as follows:
<
I guess you could look inside your downloaded code where exactly there is a +
sign (but this might not be very easy).
What I'd do?
I'd find the class/id of the DOM elements that contain the +
sign (suppose it's ".collapsible"
, and with Javascript (actually jQuery):
edit
Alright... Sorry I haven't looked at the bootstrap code... but I guess it works with something like slideToggle
, or slideDown and slideUp
... Imagine it's a slideToggle
for the elements of class .collapsible
, which reveal contents of some .info
elements. Then:
$(".collapsible").click(function() {
var content=$(".collapsible").html();
if $(this).next().css("display") === "none") {
$(".collapsible").html(content.replace("+", "-"));
}
else $(".collapsible").html(content.replace("-", "+"));
});
This seems like the opposite thing to do, but since the actual animation runs in parallel, you will check css before animation, and that's why you need to check if it's visible (which will mean it will be hidden once the animation is complete) and then set the corresponding + or -.