I have a select
; and in the last option
, I call a page.
Since it is not possible to use a button
within a select
, I used onChange
.
I wanted the last option
to be the most like 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>