Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  65] [ 2]  / answers: 1 / hits: 20648  / 8 Years ago, wed, june 22, 2016, 12:00:00

I am trying to use select field in materialize css. But it doesn't seems work properly
my code :



<div class=container>  
<div class=row>

<div class=input-field s6>
<label >OS Version</label>
<select class=validate>
<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>

</div>
</div>
</div>

<!-- Scripts-->
<script src=https://code.jquery.com/jquery-2.1.1.min.js></script>
<script src=js/materialize.js></script>
<script src=js/init.js></script>
<script type=text/javascript>
$(document).ready(function() {
$('select').material_select();
});

</script>


And in this it is rendering a select field but label is still overlapping the select field. as shown in figure:
enter



from http://materializecss.com/forms.html i have inspected where i founf this :



<div class=select-wrapper>
<span class=caret>▼</span>
<input class=select-dropdown readonly=true data-activates=select-options-6162e8f3-f286-fe44-8513-ab1ff6541fb1 value=Choose your option type=text>
<ul style=width: 358px; position: absolute; top: 0px; left: 0px; opacity: 1; display: none; id=select-options-6162e8f3-f286-fe44-8513-ab1ff6541fb1 class=dropdown-content select-dropdown>
<li class=disabled><span>Choose your option</span></li>
<li class=><span>Option 1</span></li>
<li class=><span>Option 2</span></li>
<li class=><span>Option 3</span></li>
</ul>
<select class=initialized>
<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>
</div>


and from my code i am getting this from inspect:



<div class=select-wrapper>
<span class=select-dropdown data-activates=select-options-fdd5c3a3-b6d7-07f2-6626-df40620c20cc>Choose your option</span>
<select class=validate initialized>
<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>
</div>


Missing UL element is rendering below all the div, which mean above my footer.. where i am going wrong?



Fiddle : https://jsfiddle.net/007zkvut/


More From » jquery

 Answers
4

I updated your jsfiddle because it was loading Materialize before jQuery, so $() was not defined.



Here is the link:



https://jsfiddle.net/007zkvut/7/



It is working properly, just like in their website.



However, looking at the code you posted in your question and the code in your jsfiddle, there is a difference in the placement of <label>



In my updated jsfiddle I put another select to illustrate the difference between the different <label> placements. Just make sure it is after <select>


[#61687] Sunday, June 19, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellisc

Total Points: 533
Total Questions: 82
Total Answers: 90

Location: Bangladesh
Member since Thu, Aug 5, 2021
3 Years ago
;