CSS Question

Unexpected behaviour of js in repeated actions

I use standart js and jQuery.

I have standart modal window. And since that have the following mehtods.

function closeModal(modal) {
modal.css('display', 'none');
return false;
}

function openModal(modal) {
modal.css('dislay', 'block');
return false;

}


And next using in document:

<a href="#ModalAdd" onclick="openModal($('#ModalAdd'))" class="add">Add</a>


First time this modal window, opens and closes in a good way. After closing, I can't open it again.

But next commands:

$('#ModalAdd').css('display', 'block')

$('#ModalAdd').css('display', 'none')


When i use it in browser console, give me needed result.

What issue might it be about?

(I use Ubuntu firfox, if it is important) Thanks

Answer Source

Remove the typo

function openModal(modal) {
    modal.css('display', 'block');
    return false;

}

Also toggle the display instead.

function Modal(modal){
    $(this).toggle(display);
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download