下拉菜单:如何取消激活第1(选择)选项? [英] drop down menu: how to make deactivate the 1st (selected) option?

查看:155
本文介绍了下拉菜单:如何取消激活第1(选择)选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我使用的下拉列表:

Here is the dropdown I'm using:

<form name="my_form_name">
<select name="my_ddmenu_name">
<option value="#" selected>dd menu title (should not act as a link)</option>
<option value="link to page 1">1st Link name</option>
<option value="link to page 2">2nd Link name</option>
<option value="link to page 3">3rd Link name</option>
<option value="link to page 4">4th Link name</option>
<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu1.value,'newtab')">
</select>
</form>

我需要
- 有如上所述的Go链接。用户应选择其选择的链接,然后按Go!访问所选链接。
- 如上所述在新标签页中打开链接。

It's necessary for me to - have a "Go" link, as above. Users should select their link of choice and then press "Go!" to visit the selected link. - open links in a new tab, as above.

那么,我应该如何更改上面的代码来停用第一个(已选择)选项的链接导致#)。

So, how should I change the code above to deactivate the 1st (selected) option's link (currently leading to "#").

谢谢。

推荐答案

如何:

onClick="if(ddmenu1.value !== '#')window.open(ddmenu1.value,'newtab')"

演示。

这篇关于下拉菜单:如何取消激活第1(选择)选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆