为什么图像选择器程序中的这个函数 js 不起作用
Why this function in imagepicker program js doesn't work?
我对这个功能有问题,我使用此 http://rvera.github.io/image-picker/,我想为用户创建选项,以便在选择合适的图像后转发到正确的网站。转发工作正常,但图像使用此代码消失。有什么想法吗?
<!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>
我认为您尚未初始化图像选择器。
从 http://rvera.github.io/image-picker/
然后只需在目标元素上调用图像选择器。 $("select").imagepicker()
为什么要在缩小版本中加载图像选择器.js和相同的文件?
相关文章:
- 为什么我的控制器没有启动函数.js脚本
- 在函数js中传递变量
- 如何在单独的文件中调用函数 js.
- 在铯中调用函数.js当事件被尝试时
- 只有setTimeout执行函数.JS
- 为什么图像选择器程序中的这个函数 js 不起作用
- 获取邮件中的信息.php从函数.js解析为manage.html
- 如何从应用程序中调用JS函数.js在Rails4视图中
- Uncatch TypeError: obj.attr 不是函数 JS
- 从 C++ 节点调用 JavaScript 函数.js扩展
- 调用 Backbone 内部的外部函数.js的视图初始化方法
- 如何使用 Scala 创建 JavaScript 函数.js
- 使用带有下划线循环的回调函数.js骨干.js项目不起作用
- 获取字段值的函数-JS
- 函数js不能递归调用自己的函数
- 在函数JS中创建带有地理代码的标记
- 循环内部的函数(js/jquery)
- 我需要帮助将此代码添加到jQuery函数.js文件中
- 未捕获类型:未定义不是函数JS错误
- 停止多个内联函数JS的事件传播