0

I do not know how well i remaked this code, but the biggest problem is this:

when i am clicked on menu item, than black box are showing. When i clicked in white space/background or somewhere else, than box disappeared. It is logical to assume, that when i am clicking second menu item (when first menu item is actived), than first menu item (black box) should disappear, and second menu item should be activated. However, when i am clicking second menu item, both black boxes is activated.

$(document).ready(function () {
$('#icons').click(function () {
        if ($('#chat-drop').is(":visible")) {
            $('#chat-drop').hide()
        $('#rodyti').removeClass('active');
        } else {
            $('#chat-drop').show()
        $('#rodyti').addClass('active');
        }
    return false;
});

Full code: http://jsfiddle.net/wW75v/4/

I would be grateful for any help

2 Answers 2

1

Add the following at the beginning of both click events, to clear any visible chat drop elements.

http://jsfiddle.net/wW75v/5/

$('#chat-drop,#chat-drop2').hide()

So this becomes:

$(document).ready(function () {
    $('#icons').click(function () {
        $('#chat-drop,#chat-drop2').hide(); //Add
        if ($('#chat-drop').is(":visible")) {
            $('#chat-drop').hide()
            $('#rodyti').removeClass('active');
        } else {
            $('#chat-drop').show()
            $('#rodyti').addClass('active');
        }
        return false;
    });


    $('#icons2').click(function () {
        $('#chat-drop,#chat-drop2').hide(); //Add
        if ($('#chat-drop2').is(":visible")) {
            $('#chat-drop2').hide()
            $('#rodyti2').removeClass('active');
        } else {
            $('#chat-drop2').show()
            $('#rodyti2').addClass('active');
        }
        return false;
    });



    $('#chat-drop').click(function (e) {
        e.stopPropagation();
    });
    $(document).click(function () {
        $('#chat-drop').hide();
        $('#rodyti').removeClass('active');
    });


    $('#chat-drop2').click(function (e) {
        e.stopPropagation();
    });
    $(document).click(function () {
        $('#chat-drop2').hide();
        $('#rodyti2').removeClass('active');
    });

});
Sign up to request clarification or add additional context in comments.

Comments

0

Try this :

$('#icons').click(function () {
    if ($('#chat-drop').is(":visible")) {
        $('#chat-drop').hide()
    $('#rodyti').removeClass('active');
    } else {
        $('#chat-drop').show()
    $('#rodyti').addClass('active');
        $('#chat-drop2').hide()
        $('#rodyti2').removeClass('active');
    }
return false;
});


$('#icons2').click(function () {
        if ($('#chat-drop2').is(":visible")) {
            $('#chat-drop2').hide()
        $('#rodyti2').removeClass('active');
        } else {
            $('#chat-drop2').show()
        $('#rodyti2').addClass('active');
                        $('#chat-drop').hide()
        $('#rodyti').removeClass('active');
        }
    return false;
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.