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?
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.
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.
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("-");
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With