2

I have a small form which is dynamically built using a list of URLs.

<form> 
  <select>
    <option value="google.com">google.com</option>
    <option value="bing.com">bing.com</option>
  </select>
  <button class="btn" type="button">Go!</button>
</form>

By hitting the 'Go!' button I would like to open a new window with the correct URL.

I'm pretty sure I can't do this through straight HTML but is there a jQuery way?

Thanks

4

1 回答 1

3
$('button').click(function() {
   url = $('select').val();
   window.open(url);
});
于 2012-12-28T21:42:47.103 回答