English 中文(简体)
物质化 2.0.1 : 选择中的拉贝尔问题
原标题:Materializecss 2.0.1 : problem with Label in Selects

Im using Materializecss 2.0.1 and the in the select dissapear. My code: <select required class="validate" name="id_provincia" id="id_provincia"> <option value="" disabled selected>Sel. una opción</option> <?php foreach ($data[list_provincias] as $k=>$prov){ ?> <option <?php if($prov[id]==$data[ record ][ id_provincia ]){ echo "selected= selected "; }elseif($prov[id]== 22 && !$data[ record ][ id_provincia ]){ echo "selected= selected "; } ?> value="<?php echo $prov[id]; ?>"><?php echo $prov[provincia]; ?></option> <?php } ?> </select> <label for="id_provincia">Provincia</label> <span class="helper-text">Sel. Provincia</span>

https://i.stack.imgur.com/9fuKu.png” rel=“nofollow noreferer”>。

Im try copy and pastle the example, erease all includes (except materializecss) and still the bug. "Materialize Select" is the label. This is a example in the official doc - https://materializeweb.com/select.html

问题回答

确保在投入领域完成这项工作,以便与其他案文领域适当保持一致。 如果数据[记录][id_provincia]= 不应选择第一种选择

  <div class="input-field col s12">
    <select>
      <option value="" disabled <?php if($data[ record ][ id_provincia ] == null) { ?> selected <?php } ?> >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>

初始

<script>
  document.addEventListener( DOMContentLoaded , function() {
    var elems = document.querySelectorAll( select );
    var instances = M.FormSelect.init(elems,{});
  });
    
  // Or with jQuery

  $(document).ready(function(){
    $( select ).formSelect();
  });
</script>

enter image description here

正式法典:

<!DOCTYPE html>
<html>
  <head>
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="
https://cdn.jsdelivr.net/npm/@materializecss/materialize@2.0.1-alpha/dist/css/materialize.min.css
" rel="stylesheet">

  </head>
  <body>
  
  <div class="container">
    <h2>Hello World!</h2>
  <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>
  </div>

<script src="
https://cdn.jsdelivr.net/npm/@materializecss/materialize@2.0.1-alpha/dist/js/materialize.min.js
"></script>

  <script>
    document.addEventListener( DOMContentLoaded , function() {
      var elems = document.querySelectorAll( select );
      var instances = M.FormSelect.init(elems,{});
    });

  </script>
  </body>
</html>




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签