kevin seda kevin seda - 1 year ago 119
CSS Question

Jquery toggle .css

I have this jquery code which runs fine.

$(window).load(function() {

$('.menuBtn').click(function(e) {
(this.classList.contains('is-active') === true) ? this.classList.remove('is-active'): this.classList.add('is-active');


'height': '100%',
'overflow': 'hidden'



Recently I added the last line.

'height': '100%',
'overflow': 'hidden'

When i click on the button the above css gets added.

My problem is, when i click it again it doesn't change back. Could this work with a toggle kind of ?

Answer Source

Why don't you continue your streak of classes and toggleClass()?


body.full {
    height: 100%;
    overflow: hidden;

JS (replace that last line):

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download