This code shows frm01:
$(document).ready(function() {
$("#reg").click(function () {
$("#frm01").show("slide", { direction: "down" }, 1000);
});
});
But I want to hide frm01 if it is allready visible, and vice versa. How could I do this, please ?
getElementById("title"). value; var flagu2=0; ..... ..... var flagu6=0; if( flagu1==0 && flagu2==0 && flagu3==0 && flagu4==0 && flagu6==0 ) return true; else return false; } function clearBox(type) { // Your implementation here } // Event handler $submitButton. on('click', handleSubmit); });
$ is pretty commonly used as a selector function in JS. In jQuery the $ function does much more than select things though. You can pass it a selector to get a collection of matching elements from the DOM. You can pass it a function to run when the document is ready (similar to body.
In JavaScript we have the following conditional statements: Use if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.
Try jQuery's toggle()
method:
$(function() {
$("#reg").click(function () {
$("#frm01").toggle(1000);
});
});
You don't 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);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With