我如何href这个列表/选项?

时间:2016-12-25 04:14:08

标签: javascript html css



#episode-list {
  padding: 1em;
  margin: 1em auto;
  border-top: 5px solid #69c773;
  box-shadow: 0 2px 10px rgba(0,0,0,.8)
}

input {
  width: 100%;
  padding: .5em;
  font-size: 1.2em;
  border-radius: 3px;
  border: 1px solid #d9d9d9
}

<div id="episode-list">
  <input type="text" id="default" list="episodes" placeholder="Episodes">
  <datalist id="episodes">
      <option value="HTML">S1 E1</option>
      <option value="CSS">S1 E2</option>
      <option value="JavaScript"></option>
      <option value="Java"></option>
      <option value="Ruby"></option>
      <option value="PHP"></option>
      <option value="Go"></option>
      <option value="Erlang"></option>
      <option value="Python"></option>
      <option value="C"></option>
  </datalist>
</div>
&#13;
&#13;
&#13;

怎么做这个?

有人请帮帮我。

就像我想要这样做,如果有人点击选项,他们会链接到URI / URL

提前致谢

2 个答案:

答案 0 :(得分:0)

试试这个:

<select id="episodes" onchange="location = this.value;"> <!-- when an option is selected, redirect to the value !--> 
    <option value="./location1.php">Location1</option> <!-- change values to what is required !-->
    <option value="./location2.php">Location2</option>
    <option value="./location3.php">Location3</option>
</select>

参考:using href links inside <option> tag。一定要给原始人的想法一个upvote:)

答案 1 :(得分:-1)

使用select而不是像这样的输入

import org.exolab.jms.administration.AdminConnectionFactory;
import org.exolab.jms.administration.JmsAdminServerIfc;

// ...
    String url = "tcp://localhost:3035/";
    JmsAdminServerIfc admin = AdminConnectionFactory.create(url);

    String topic = "mytopic";
    Boolean isQueue = Boolean.FALSE;
    if (!admin.addDestination(topic, isQueue)) {
        System.err.println("Failed to create topic " + topic);
    }

然后将这些脚本文件放在

<select id="default" multiple="true"  style="width:400px;" >
   <div id="txtHint"> 
   <option value="HTML">S1 E1</option>
        <option value="CSS">S1 E2</option>
        <option value="JavaScript"></option>
        <option value="Java"></option>
        <option value="Ruby"></option>
        <option value="PHP"></option>
        <option value="Go"></option>
        <option value="Erlang"></option>
        <option value="Python"></option>
        <option value="C"></option>
  </div>
</select><br/>


现在写下这个:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.css">
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.js"></script>