Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Google Docs
Each Attachment size should not exceed 1.0 MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Move this topic
Forum :
Getting Started
Using jQuery
Using jQuery Plugins
Using jQuery UI
Developing jQuery Core
Developing jQuery Plugins
Developing jQuery UI
QUnit and Testing
About the jQuery Forum
jQuery Conferences
jQuery Mobile
Developing jQuery Mobile
Sub forum :
Move this topic
Cancel
Getting Started
timlajoh
Need help with my code
in
Getting Started
•
8 years ago
$(document).ready(function(){
var x = true;
$("#Menubutton").click(function(){
if (x == true) {
$(".DropDown").slideUp(1000);
$("#drop2").slideUp(1000);
alert("true");
x = false;
}
if( x == false) {
$(".DropDown").slideDown(1000);
$("#drop2").slideDown(1000);
alert("false");
x = true;
}
});
});
To my Problem I want to click on a button (div) and want to slideUp a div. And when i click it on the second time i want that it slide down. Have anybody an idea how i can solve my problem?
Thank you
1
Replies(6)
jakecigar
Re: Need help with my code
8 years ago
Try…
$(document).ready(function () {
var x = true;
$("#Menubutton").click(function () {
if (x) {
$(".DropDown").slideUp(1000);
$("#drop2").slideUp(1000);
alert("true");
x = false;
}else{ // <--- else!
$(".DropDown").slideDown(1000);
$("#drop2").slideDown(1000);
alert("false");
x = true;
}
});
});
JΛ̊KE
timlajoh
Re: Re: Need help with my code
8 years ago
THANK YOU SOO MUCH!
It worked!! I'm so happy!
Best Forum ever (y)
Greetings
Leave a comment on jakecigar's reply
kbwood.au
Re: Need help with my code
8 years ago
Or this:
$(function() { // Shorthand for $(document).ready(function() {
$('#Menubutton').click(function() {
$('.DropDown,#drop2').
slideToggle
(1000);
});
});
timlajoh
Re: Re: Need help with my code
8 years ago
The solution above worked well. I don't tried this but thank you anyway for your help !
Greetings
Leave a comment on kbwood.au's reply
jakecigar
Re: Need help with my code
8 years ago
We each took different routes to solve your problem. I made minimal changes to your code, while Keith wrote optimal code.
I hope you understand how all your code boiled down to his few lines. It will make you a better programmer.
JΛ̊KE
timlajoh
Re: Re: Need help with my code
8 years ago
Yeah you are right :)
Thank you
Leave a comment on jakecigar's reply
Change topic type
Topic Type :
Discussions
Questions
Ideas
Problems
No of days :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Change topic type
Cancel
Link this topic
Provide the permalink of a topic that is related to this topic
Permalink
Save
Close
Reply to timlajoh's question
Top
Reply
{"z43356968":[14737000005779704,14737000005790153,14737000005790155,14737000005790173],"z2953500":[14737000005781322],"z2950240":[14737000005779715,14737000005790171]}
Statistics
6
Replies
2088
Views
1
Followers
Tags
Cancel
greenhorn
need
if
noob
help
Actions
Permalink