如何将此选项添加到此图像选取器项目中
How do I add this option to this image-picker project?
>我有一个问题。这个概念是我有 4 个可点击的图像由这个 http://rvera.github.io/image-picker/创建,我想创建选项,在单击按钮并选择适当的图像后将某人转发到适当的 href 链接。例如,如果我点击带有猫的图像,然后点击按钮,它会将我转发到有关猫的页面。如果我点击带有狗和按钮的图像,它会将我转发到有关狗的页面,如果我单击带有狗和猫和按钮的图像,它会将我转发到有关狗和猫的页面。
<html>
<head>
<link rel="stylesheet" href="css.css">
<script src="js.js"></script>
<!-- scripts for imagepicker -->
<link rel="stylesheet" href="image-picker.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="image-picker.js"></script>
<script type="text/javascript" src="image-picker.min.js"></script>
</head>
<body>
<!--code for imagepicker-->
<select multiple="multiple" class="image-picker show-html">
<option data-img-src="http://placekitten.com/220/200" href="http://cats.com" value="1">Cute Kitten 1</option>
<option data-img-src="http://placekitten.com/180/200" href="http://dogs.com" value="2">Cute Kitten 2</option>
<option data-img-src="http://placekitten.com/130/200" href="http://dogsandcats.com" value="3">Cute Kitten 3</option>
</select>
<button href="#">Forward</button>
<script>
$("select").imagepicker()
</script>
</body>
</html>
我该怎么做?我完全不知道:/。
告诉我这是否有效。我添加了一个脚本,当您更改选择时,该脚本会更改值。
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="css.css">
<script src="js.js"></script>
<!-- scripts for imagepicker -->
<link rel="stylesheet" href="image-picker.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="image-picker.js"></script>
<script type="text/javascript" src="image-picker.min.js"></script>
<script type="text/javascript">
"use strict";
//wait for the page to be fully loaded
window.onload = function() {
initialize();
}
</script>
</head>
<body>
<!--code for imagepicker-->
<select multiple="multiple" class="image-picker show-html" id="selectImg">
<option data-img-src="http://placekitten.com/220/200" value="http://cats.com">Cute Kitten 1</option>
<option data-img-src="http://placekitten.com/180/200" value="http://dogs.com">Cute Kitten 2</option>
<option data-img-src="http://placekitten.com/130/200" value="http://dogsandcats.com">Cute Kitten 3</option>
</select>
<button href="#" id="forwardButton">Forward</button>
<script>
function initialize() {
var choice = document.getElementById("selectImg").value;
//changes destination when you set or change your choice
document.getElementById("selectImg").onchange = function() {
choice = document.getElementById("selectImg").value;
}
//when button is clicked
document.getElementById("forwardButton").onclick = function() {
if (choice !== ("" || "undefined")) {
window.location = choice;
}
}
}
</script>
</body>
</html>
相关文章:
- 正在将数据主题添加到所有项目
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 如何检查管道中未定义的项目
- 有没有一种方法可以添加相同的项目val=“0”;4〃;到JavaScript中数组的每个对象
- 学生搜索项目jquery/javascript
- 如何获取不属于我项目的上一页的URL
- Dojo:访问dijit.form.Select中单击的项目
- 角度的项目列表 ng 重复,ng 单击显示全宽描述
- 我需要为我的朋友在这个项目上提供帮助
- 如何从 HTML 查询中删除项目
- 在Meteor项目中安装并包含npm模块后出错
- 当在Ember中点击一个项目时,我如何将一个活动类添加到项目列表中
- 将单击事件添加到附加的项目中
- 通过另一个php应用程序将我的项目推送到Github存储库中
- 在javascript中搜索项目列表的性能
- 如何将本地依赖项添加到npm项目中
- angularjs移除焦点上的活动类并添加到下一个项目
- 为什么react/redux前端项目在package.json中包含生产依赖项
- 从下拉列表中的数组中选取某个项目,然后将其显示为第一项并按字母顺序显示
- 如何将此选项添加到此图像选取器项目中