change icon on menu link click

user3300065

On my menu I have a font awesome icon that I would like to be able to change once click on parent link.

I am trying to get it if menu link is closed will show

And if menu link is open will show

Currently my java script not working.

I can only get it to change if change it manually but trying to get java script to do so.

<?php echo Modules::run('admin/common/header/index');?>
<div id="wrapper">
<nav class="navbar navbar-inverse" role="navigation">

</nav>

<div class="menu">
    <ul class="nav navbar-nav menu">
        <li>
            <a class="parent" data-toggle="collapse" data-target="#setting"><i class="fa fa-cog"></i> System <span class="pull-right"><i class="fa fa-angle-right"></i></span></a>
            <ul id="setting" class="collapse">
                <li class="third-level">
                    <a data-toggle="collapse" data-target="#user"><i class="fa fa-angle-double-right"></i> First Level</a>
                    <ul id="user" class="collapse">
                        <li>
                            <a href="#"><i class="fa fa-angle-double-right"></i> Second Level</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</div>



<div id="page-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <h1><i class="fa fa-tachometer"></i> Dashboard <small>Dashboard Home</small></h1>
                <div class="alert alert-success alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                </div>
            </div>
        </div>
    </div>
</div>


</div>

<script type="text/javascript">
$('.parent').on('shown.bs.collapse', function() {
$(".parent").addClass('fa fa-angle-right').removeClass('fa fa-angle-down');
});
</script>
<?php echo Modules::run('admin/common/footer/index');?> 
Austin Greco

You need to attach the listener to the object that is actually collapsing:

$('#setting').on('shown.bs.collapse', function() {
  $(".parent").addClass('fa fa-angle-right').removeClass('fa-angle-down');
});

#setting is the element being collapsed, so the event happens there.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Change font awesome icon on click menu bars

From Dev

Foundation 6 menu icon been show on click link

From Dev

Change a folder's icon with a custom right click menu

From Dev

Change the color of menu icon

From Dev

Close menu on click link

From Dev

change icon on click with materializecss

From Dev

Change icon on li click?

From Dev

Change icon on click jstree

From Dev

Button Icon Change on Click

From Dev

change icon on click with materializecss

From Dev

Right click on desktop icon then click on menu item

From Dev

Android change actionBar icon menu

From Dev

Change the Arrow Icon in the Drawer Menu?

From Dev

Change icon on MATE main menu

From Dev

Change broken link icon in Ember

From Dev

How to Click Sub Menu Link in Main Menu

From Dev

change icon of a List with a Click with CSS

From Dev

bootstrap accordion icon change in click

From Dev

Applescript to click on a specific icon in the Mac Menu Bar

From Dev

Is there an icon pack for nautilus right click menu?

From Dev

Is there an icon pack for nautilus right click menu?

From Dev

Crash when i click menu icon with slidingmenu

From Dev

jquery toggle menu icon when click function

From Dev

Navigation drawer not open on menu icon click on toolbar

From Dev

how to open the Navigation drawer on the click of menu Icon?

From Dev

Popup menu on click of action bar Icon

From Dev

How to change this click menu to hover menu?

From Dev

Menu icon does not open menu after clicking a link

From Dev

Close of menu and icon image when click on another menu?