导航菜单
网站标志
技术支持
select标签中<option>标签如何设置为超链接形式
作者:系统管理员    发布于:2025-07-10 18:55:53    文字:【】【】【
方式一:给监听select标签的change事件使用window.open()进行跳转


<select onchange="window.open(this.options[this.selectedIndex].value,target='_blank')">
        <option value="">请选择</option>
        <option value="https://blog.csdn.net/m0_73334325?spm=1001.2101.3001.5343">测试文字</option>
</select>
-------------------------------------------------------------------
<body>
  <select name="select" onchange="mbar(this)">
    <option value="省重要网站">省重要网站</option>
    <option value="http://www.ln.gov.cn/"> 辽宁省</option>
</select>
<script>
  function mbar(eventHtml){
    var targetUrl = eventHtml.options[eventHtml.selectedIndex].value;
    if(targetUrl!=''){
       open(targetUrl,'_blank')
    }
  }
</script>
</body>


方式二:给监听select标签的change事件使用location.href进行跳转


<select name="select" onchange="self.location.href='options[selectedIndex].value'">
    <option value="省重要网站">省重要网站</option>
    <option value="http://www.ln.gov.cn/"> 辽宁省</option>
</select>
浏览 (96) | 评论 (0) | 评分(0) | 支持(0) | 反对(0) | 发布人:系统管理员
将本文加入收藏夹
相关评论
最新点评
更多点评 发表点评
发表评论
您的评价
差(1) 一般(2) 好(3) 很好(4) 非常好(5)
评论标题
评论内容
验 证 码
看不清?更换一张
匿名发表 
文章搜索
脚注信息

电脑家 Copyright(C)2010-2024        苏ICP备10028559号-1