簡體   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