Materialize CSS select statement not showing

14,638

Solution 1

Try this:

<body>
  <div class="input-field col s12">
    <select>
      <option value="" disabled selected>Choose your option</option>
      <option value="1">Option 1</option>
      <option value="2">Option 2</option>
      <option value="3">Option 3</option>
    </select>
    <label>Materialize Select</label>
  </div>
  <!--Import jQuery before materialize.js-->
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
  <script type="text/javascript" src="js/materialize.min.js"></script>
  <script>
     $(document).ready(function() {
        $('select').material_select();
    });
  </script>

</body>

Solution 2

You need use a class "browser-default" to show the select combo. Like this:

<select name="name" class="browser-default"><option>- options -</option></select>

Solution 3

i had same problem in 2019, these answers helped, but a little update cause of the Materialize version upgraded M's select and form are better than browser-default one:)

now the initialization code is changed to

  $(document).ready(function(){
    $('select').formSelect();
  });

https://materializecss.com/select.html

Share:
14,638
Constantly Confused
Author by

Constantly Confused

Python programmer, I mostly scan the tkinter tag and try to help when I can. I have some experience in HTML, CSS and node.js

Updated on September 01, 2022

Comments

  • Constantly Confused
    Constantly Confused over 1 year

    Although this question has already been asked in this thread:

    Materialize CSS - Select Doesn't Seem to Render

    I'm having problems with where to place this code:

    $(document).ready(function() {
        $('select').material_select();
    });
    

    At the moment, the most logical thing I can think of is to place it like so:

    <body>
      <!--Import jQuery before materialize.js-->
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
      <script type="text/javascript" src="js/materialize.min.js">
        $(document).ready(function() {
            $('select').material_select();
        });
      </script>
    
      <div class="input-field col s12">
        <select>
          <option value="" disabled selected>Choose your option</option>
          <option value="1">Option 1</option>
          <option value="2">Option 2</option>
          <option value="3">Option 3</option>
        </select>
        <label>Materialize Select</label>
      </div>
    </body>
    

    I've tried changing the "document" to the name of my document, in this case "index", but it still doesn't work.

    Am I just being slow?

    Thanks in advance.