html - Jquery only add without removing class -


i need jquery.i need menu button change "menu button" "x"(which cancel button).but problem jquery adds class in console , in inspector,and doesnt change menu icon.. says class added... here code:

$('.tablet-icon').click(function() {    if ($('.tablet-icon').hasclass('form-active')) {      $('.tablet-icon').removeclass('form-active');      console.log('is-removed');      return false;    } else {      $('.tablet-icon').addclass('form-acive');      console.log('is-added');      return false;    }  });
.tablet-icon {    position: absolute;    padding: 0;    margin: 0;    right: 0;    left: 85%;    top: 22px;    width: 40px;  }  .tablet-icon:before {    width: 100%;    font-size: 1.6em;    display: block;    font-family: "eleganticons";    font-weight: bold;    text-align: center;    content: "\61";  }  .tablet-icon:before::after {    clear: both;    content: "";    display: table;  }  .tablet-icon.form-active:before {    font-size: 1.6em;    line-height: .9em;    content: "\4d";  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <span class="tablet-icon"></span>

pm:im working on wordpress.

credits ilwcss

problem: line

$('.tablet-icon').addclass('form-acive');

a typo error.. form-acive must form-active

just use toggleclass() simplyfy task.

$('.tablet-icon').click(function() { $(this).toggleclass('form-active'); });


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -