Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having Issue On Bootstrap 3 SlideDown() hidden Element

Can you please take a look at this demo and let me know why the change() function is not able to slideDown() a hidden element in Bootstrap 3?

Here is the code I have

$(function() {
    $('input:radio').change(function() {
        if($(this).val()== 'Dog') {
            $('#hidden-list-1').slideDown();
        }
        if($(this).val()== 'Bird'){
            $('#hidden-list-2').slideDown();  
        }
    });
});
like image 615
Suffii Avatar asked Jul 05 '15 18:07

Suffii


2 Answers

As the other answers have already mentioned the issue is boostrap has a style like this

.hidden{
  display: none !important;
}

One way to solve this is by removing hidden class.

$('#hidden-list-1').hide().removeClass('hidden').slideDown();

Here is a demo https://jsfiddle.net/dhirajbodicherla/zzdL5jp7/3/

like image 76
Dhiraj Avatar answered Nov 17 '22 01:11

Dhiraj


It seems to be an issue of the important tag in CSS. From the Bootstrap documentation (http://getbootstrap.com/css/), the show and hidden classes are marked with important:

   .show {
      display: block !important;
    }
    .hidden {
      display: none !important;
    }

The css changes applied by jQuery slideDown() are most likely getting ignored. If you take this out and replace with a style="display:none;" without the important, the slideDown() will work. I added that to the fiddle: https://jsfiddle.net/zzdL5jp7/1/

like image 24
grdevphl Avatar answered Nov 17 '22 00:11

grdevphl