Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  44] [ 4]  / answers: 1 / hits: 47590  / 12 Years ago, fri, october 26, 2012, 12:00:00

I need to hide a div if another div has a class.



I've created a very basic example HERE



I need the div on the bottom to hide when the word click is.. well.. clicked. It adds a class to the middle div just fine, but it seems hasClass() doesn't want to work?



NOTE: The structure needs to be like this. If click is clicked, modify the middle div (add class?), and manipulate the bottom div based on the middle div. With this setup - I can't just do if CLICK is clicked, slideUp() the bottom div.



Also, once ok or cancel is clicked, it will revert, because the middle div will no longer have the class. Provided that's the method I can get working here, haha.


More From » jquery

 Answers
50

your if statement is outside of any function, so there is no reason for it to be called after the script is loaded.



See this fiddle, I think that's what you want.


[#82326] Thursday, October 25, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josiah

Total Points: 208
Total Questions: 105
Total Answers: 107

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
;