user7170464
user7170464

Reputation: 1

HTML Code for Font Awesome Plus/Minus Icon Switch

I manage a knowledge base using Adobe RoboHelp. Very rarely need to use HTML over the standard editor. I want to have a dropdown that has the font awesome icon fa-plus-circle turn into the fa-minus-circle when the user clicks the text.

I am struggling with the HTML code to turn the plus icon into the minus icon when clicked. Any help would be much appreciated!

Upvotes: -1

Views: 2415

Answers (1)

MomasVII
MomasVII

Reputation: 5071

Something like this will work. But using jQuery would be easier if you could.

<script>
function changeIcon() {
    var isChecked = document.getElementsByClassName('fa-minus');
    if(isChecked.length > 0) document.getElementById('plus').className='fa fa-plus';
    else document.getElementById('plus').className='fa fa-minus';
}
</script>

<i class="fa fa-plus" id="plus"></i><div onclick="changeIcon();">Click Me</div>

Hard to determine the way that best suits you without code.

Upvotes: 0

Related Questions