Visit selected link on button

前端 未结 2 375
时光取名叫无心
时光取名叫无心 2021-01-29 17:07

How can I visit a selected link from drop-down list on external button in a new window?


    
    


JS

var button = document.getElementById("myButton");
button.addEventListener("click", function() { 
    var select = document.getElementById('select');
    var win = window.open(select.options[select.selectedIndex].value, "_blank");
    win.focus();

},false);

DEMO

提交回复
热议问题