The slide down function is fine but i need to change both text and a font awesome icon in the button from 'open all questions (down icon)' to 'Close all questions (up icon)' when the button is clicked, then reverting to 'open all questions' on close. Thanks! [
$(document).ready(function(){
$("#showNavBut").click(function() {
$("#showNav").slideToggle();
if ( $('#showNav').css('display').display == 'block' ) {
$('#showNavBut').html('Close all questions <i class="fas fa-chevron-up" aria-hidden="true"></i>'); // Change button text
}
else {
$('#showNavBut').html('Open all questions <i class="fas fa-chevron-down" aria-hidden="true"></i>'); // Change button text
}
});
});
#showNav {display: none;}
<link href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div id="showNav">
<div class="#">
<a href="#">Confidence Household 1</a>
<a href="#">Confidence Household 2</a>
<a href="#">Confidence Household 3</a>
<a href="#">Confidence-Household 3</a>
</div>
</div>
<button id="showNavBut" class="show-nav-but" style="width: auto;">Open all questions <i class="fas fa-chevron-down" aria-hidden="true"></i></button>
</div>
]1