NewPHPer
NewPHPer

Reputation: 237

Visibility of select tag

I am trying to play with visibility of select tag,

Here is HTML Code;

<div id="dialog">
            <label id="">Hi</label><input type="text" id="input-name" />
            <select id="select-asd" class="selectpicker" name="Name" style="display:none;" hidden></select>
        </div>

I've already tried visibility and display properties, but I could not get any result.

Here is JavaScript Code;

var selectAsd = document.getElementById( 'select-asd' );
selectAsd.style.display = 'none';

Thanks in Advance

UPDATE** I think The problem is because of the "selectpicker"

Upvotes: 0

Views: 2973

Answers (3)

NewPHPer
NewPHPer

Reputation: 237

Here is the answer;

Since the select tag's class is selectpicker, the following code should be used to hide/show elements;

$( "#select-asd" ).selectpicker( "hide" );

Upvotes: 0

Alex
Alex

Reputation: 1593

Try to put your JS code into

window.onload = function() {
...
};

Upvotes: 0

Sumeet Gavhale
Sumeet Gavhale

Reputation: 800

Try this... If you want to make the select visible just uncomment the javascript 2nd line

var selectAsd = document.getElementById( 'select-asd' );
selectAsd.style.display = 'none';
<div id="dialog">
  <label id="">Hi</label>
  <input type="text" id="input-name" />
  <select id="select-asd" class="selectpicker" name="Name"></select>
</div>

Upvotes: 1

Related Questions