How to write jquery If else statement?
How to write jquery If else statement?
Try jQuerys toggle()
method:
$(function() {
$(#reg).click(function () {
$(#frm01).toggle(1000);
});
});
You dont need jQuery to use if-else statements; Javascript implements those natively…
$(function() {
$(#reg).click(function () {
if ($(#frm01).is(:visible))
$(#frm01).slideUp(1000);
else
$(#frm01).slideDown(1000);
});
});
try this:
$(document).ready(function() {
$(#reg).click(function () {
if ($(#frm01).is(:hidden)) {
$(#frm01).show(slide, { direction: down }, 1000);
} else {
$(#frm01).hide(1000);
}
});
});
How to write jquery If else statement?
$(#reg).on(click, function () {
$(#frm01:hidden).show(slide, { direction: down }, 1000);
$(#frm01:visible).hide(slide, { direction: up }, 1000);
});
or
$(#reg).toggle(
function () {
$(#frm01).show(slide, { direction: down }, 1000);
},
function(){
$(#frm01).hide(slide, { direction: up }, 1000);
}
);
should also work