繁体   English   中英

为什么imagepicker程序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/

然后只需在目标元素上调用imagepicker。 $( “选择”)。imagepicker()

为什么要以最小版本加载image-picker.js和相同文件?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM