Hello everyone, I'm new. I need help to modify code
The problem that I need help: when I click "button 1" (this shows "Content 1") after click on "button 2"(not hidden "content 1")
Is there any way
to fix this please?
Demo: http://jsfiddle.net/EhJfn/32/
- //button 1:
- $(function() {
- $('#button1').click(function(event) {
- $(this).toggleClass('f_btn1');
- event.stopPropagation();
- $('#content1').slideToggle();
- });
- $(document).click(function(event) {
- if ($(event.target).closest('#content1').length == 0) {
- $('#content1').slideUp();
- $('#button1').removeClass('f_btn1');
- }
- });
- });
- //button 2:
- $(function() {
- $('#button2').click(function(event) {
- $(this).toggleClass('f_btn2');
- event.stopPropagation();
- $('#content2').slideToggle();
- });
- $(document).click(function(event) {
- if ($(event.target).closest('#content2').length == 0) {
- $('#content2').slideUp();
- $('#button2').removeClass('f_btn2');
- }
- });
- });