选择移动网站的菜单

时间:2013-03-13 09:38:51

标签: javascript jquery html css html5

我想为移动网站制作选择菜单.. 我把精选的HTML代码放在我的页面中

  <select id="menu_mobile"> 
<option value="" selected="selected">Navigation</option>
<option value="http://kudu.com.sa/en/about/who-we-are">  Who we are</option>
<option value="index.html">  Home</option>
<option value="index.html">  --Profile</option>
<option value="index.html">  --Franchise</option>
<option value="index.html">  --CSR</option>
<option value="index.html">  Home</option>

</select>

但是当我在iphone上打开我的网站时 它只选择不点击

我该如何解决呢?

2 个答案:

答案 0 :(得分:2)

我认为您的意思是浏览器未导航到<select>的值。

的jQuery

$(document).ready( function() {
   $('#select').change( function() {
      location.href = $(this).val();
   }
});

<form action="">
    <select id="select">
        <option value="">Choose a site</option>
        <option value="/internal/location.htm">Location</option>
        <option value="http://external.site.com/">Other</option>
    </select>
</form>

的JavaScript

<form>
    <select onchange="window.location.href=this.form.URL.options[this.form.URL.selectedIndex].value" name="URL">
        <option value="">Choose a site</option>
        <option value="/internal/location.htm">Location</option>
        <option value="http://external.site.com/">Other</option>
    </select>
</form>

答案 1 :(得分:0)

试试这个

$("select").change(function() {
  window.location = $(this).find("option:selected").val();
});

其工作see this fiddle 我认为你没有在你的代码中添加一个jquery