Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change accordion header with plus and minus symbol?

I don't like the default Accordion icons and I want to change them. This link here:

http://jqueryui.com/demos/accordion/#option-header

shows the option to change the header but it requires to specify icons. I don't need icons. I just need a simple (+) and (-)

How can I do that with accordions?

like image 473
Tim Tom Avatar asked May 19 '12 03:05

Tim Tom


People also ask

How do you add plus minus sign in accordion?

Simply put the span tags into your HTML where you want the plus or minus to be, and then add the css rule to your stylesheet. If using bootstrap 3 or earlier, you can use glyphicons instead of the plain text plus and minus I used.

How do I add an icon to my accordion?

You can add the icon custom css class to the Accordion header using 'iconCss' property and also add css styles to the defined class. The accordion icon element is rendered before the header text in the DOM element.


1 Answers

Hiya working sample demo http://jsfiddle.net/zM5Vj/ or http://jsfiddle.net/zM5Vj/show/

Hope this helps, + will be shown when accordion is collapsed where as - in case of open accordion.

have a nice one!

Jquery code which adds + and - accordingly Rest full code is in fiddle, If you want I can copy paste the whole code. Please let me know how it goes!

$(function(){
 $('#accordion .fullChild>a.opener').text('+').addClass('box');

  $('#accordion .opener').click(function() {
  if($(this).text() == "-") {
  $(this).text("+");
  }
  else {
  $('#accordion .opener').text("+");
  $(this).text("-");
  }
});
});
like image 55
Tats_innit Avatar answered Oct 12 '22 23:10

Tats_innit