Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h3>Búsqueda en listas desplegables mediante Datalist</h3>
<h4>Introduce tu editor de texto favorito</h4>
<input list=text_editors>
<button>▼</button>
<datalist id="text_editors">
    <select multiple size=8>
      <option value="Atom">Atom
      <option value="Brackets">Brackets		
      <option value="Notepad ++">Notepad ++
      <option value="Notepad">Notepad
      <option value="Sublime Text">Sublime Text
      <option value="TextEdit">TextEdit
      <option value="TextMate">TextMate
      <option value="Wordpad">Wordpad
    </select>
  </datalist>
              
            
!

CSS

              
                body {
  text-align: center;
}

body,
input,
button {
  font-family: palatino;
  font-size: 12pt;
}

input {
  width: 250px;
  height: 30px;
  padding: 3px;
  border: 1px solid #DDE1E4;
}

select {
  width: 258px;
  position: relative;
  left: -17px;
  margin: 0;
  border: 1px solid #DDE1E4;
  border-top: none;
  font-size:9pt;
}

datalist {
  display: none;
}

option {
  padding: 3px;
}

option:hover {
  background-color: #FFD012;
}

button {
  width: 30px;
  height: 38px;
  position: relative;
  left: -5px;
  border: 1px solid #DDE1E4;
  border-left: none;
  background-color: #FFD012;
  cursor: pointer;
}

h3,
h4 {
  text-align: center;
}


/* Para ocultar la flecha del datalist en WebKit */


input::-webkit-calendar-picker-indicator {
  display: none;
}
              
            
!

JS

              
                button = document.querySelector('button');
datalist = document.querySelector('datalist');
select = document.querySelector('select');
options = select.options;

/* Al hacer clic en el botón de flecha, mostrar/ocultar el DDL */
button.addEventListener('click', toggle_ddl);

function toggle_ddl() {
  if (datalist.style.display === '') {
    datalist.style.display = 'block';
    this.textContent = "▲";
    /* Si el campo de entrada ya tiene un valor, seleccionar esa opción del DDL */
    var val = input.value;
    for (var i = 0; i < options.length; i++) {
      if (options[i].text === val) {
        select.selectedIndex = i;
        break;
      }
    }
  } else hide_select();
}

/* Cuando el usuario selecciona una opción del DDL, escribirla en el campo de texto */
select.addEventListener('change', fill_input);

function fill_input() {
  input.value = options[this.selectedIndex].value;
  hide_select();
}

/* Cuando el usuario desea escribir en el campo de texto, ocultar el DDL */
input = document.querySelector('input');
input.addEventListener('focus', hide_select);

function hide_select() {
  datalist.style.display = '';
  button.textContent = "▼";
}

              
            
!
999px

Console