Search code examples
javascriptjqueryaddclassremoveclasstoggleclass

jQuery if hasclass addclass


this is what i have so far - i'm trying to get the text only to show when the 'timelineTile' is made bigger..

$(function () {
    $('.timelineTile').click(function (evt) {
        evt.stopPropagation();
        $('.selected').children().not(this).removeClass('clicked');
        $(this).toggleClass('clicked');

        if($('.selected').children().hasClass("clicked")){
            $('.details').addClass('show');
        }
    });

    $(document).click(function () {
        $('.timelineTile').removeClass('clicked');
        $('.details').removeClass('show');
    });
});

fiddle also


Solution

  • Add the following css as well to show text only when box is bigger

    .timelineTile table{
        display: none;
    }
    .timelineTile.clicked table{
        display: block;
    }