This is an anchor / toggle which opens and closes a drawer like navigation. I want the icon / text to change once it's clicked. But my jQuery is so basic i'm struggling with this atm.
<a data-target=".navbar-responsive-collapse" data-toggle="collapse" class="btn btn-navbar ss-icon drawer"></a>
Help is appreciated. /Paul
This is an anchor / toggle which opens and closes a drawer like navigation. I want the icon / text to change once it's clicked. But my jQuery is so basic i'm struggling with this atm.
<a data-target=".navbar-responsive-collapse" data-toggle="collapse" class="btn btn-navbar ss-icon drawer"></a>
Help is appreciated. /Paul
Share Improve this question asked Jun 6, 2013 at 6:52 KortschotKortschot 9771 gold badge8 silver badges21 bronze badges1 Answer
Reset to default 8This should do .
$('.btn.btn-navbar').on('click', function(e) {
e.preventDefault();
$(this).text(function(i,v) {
return v === 'Show' ? 'Hide' : 'Show';
});
});
Check Fiddle
Try this approach
var flag = true;
$('.btn.btn-navbar').on('click', function(e) {
e.preventDefault();
$(this).html(function(i,v) {
return flag === true ? 'ת' : '';
});
flag = !flag;
});
Updated Fiddle