<button type="button" id="eye" class="btn btn-default" onclick="show()"> <i class="fa fa-eye"></i> </button> <script> function show() { $('#eye').find("i").toggleClass("fa-eye fa-eye-slash"); } </script>