TonalDev
TonalDev

Reputation: 583

Close a dialog in jQuery

I have a calendar in my page which have a more info button.

That button opens when clicked upon but do not close.

How can i close it?

Button:

$('a.cmoreinf').live('click', function() {
    $('.ccontent').each(function() {
        $(this).css('display','none');
    });
    $(this).closest('.calsingleentry').find('.ccontent').css('display','block');
    return false;
});

Calendar Page

Upvotes: 0

Views: 61

Answers (2)

sjain
sjain

Reputation: 23356

The class ccontent is inside the div calsingleentry.

Use this:

$('a.cmoreinf').live('click', function() {
    $('calsingleentry').find('.ccontent').each(function() {
        $(this).css('display','none');
    });
    $(this).closest('.calsingleentry').find('.ccontent').css('display','block');
    return false;
});

Upvotes: 1

Kyle
Kyle

Reputation: 22278

I don't have all the information needed to really answer this question but I believe you're wanting to have a modal appear on the first click, disappear on the second, appear on the third etc... basically toggling the display property. If so...

$('a.cmoreinf').on('click', function(e){
  e.stopPropagation();
  $('.ccontent').hide();
  $(this).closest('.calsingleentry').find('.ccontent').toggle();
});

jQuery toggle()

Upvotes: 1

Related Questions