3
I have a select
; and, on the latter option
, I call a page.
As it is not possible to use a button
within a select
, I used the onChange
.
I wanted the last option
was the closest thing to a button
in
CSS.
var select = document.querySelector('select');
select.addEventListener('change', function () {
var selecionada = this.options[this.selectedIndex];
var url = selecionada.getAttribute('data-url');
if (url) window.location = url;
});
HTML:
<select>
<option>1</option>
<option>2</option>
<option data-url="/page.htm">Button</option>
</select>
Unfortunately, using css you can only edit the background and font color, but you can simulate a select using a list (ul)
– Tobias Mesquita
Not possible, you can’t just put the button outside the <select>?
– PauloHDSousa