第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

不知道為什么第二個 if else 條件不起作用

不知道為什么第二個 if else 條件不起作用

慕妹3242003 2022-05-26 16:29:48
即使我選擇了圖像和日期,代碼也不起作用。此外,如果我選擇 2020 年 n 說我選擇了第一張圖片,它應該轉到指定的重定向頁面...當我選擇 2021 年時,相同的第一張圖片應該轉到另一個頁面...如果我使用 else if 給條件“2020 n img”不起作用。對于圖像:<div class="swiper-container">            <div class="swiper-wrapper">                <form>                    <div id="img" class="swiper-slide"                        style="background-image: url(./img/nature.png)">                        <b>nature</b>                    </div>                </form>                <div id="img1" class="swiper-slide"                    style="background-image: url(./img/nature1.png)">                    <b>nature1</b>                </div>                <div id="img2 "class="swiper-slide"                    style="background-image: url(./img/nature2.png)">                    <b>nature2</b>                </div>            </div>            <!-- Add Pagination -->            <div class="swiper-pagination"></div>        </div>日期選擇器:    <div id="picker">        <p align="center">            <b>Year:</b> <input type="text" id="datepicker">        </p>    </div><script>  $(function() {        $('#datepicker').datepicker({            changeYear: true,            showButtonPanel: true,            dateFormat: 'yy',            onClose: function(dateText, inst) {                 var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();                $(this).datepicker('setDate', new Date(year, 1));            }        });       $("#datepicker").focus(function () {            $(".ui-datepicker-month").hide();            $(".ui-datepicker-calendar").hide();        });    });  </script>[enter image description here][2]
查看完整描述

2 回答

?
ITMISS

TA貢獻1871條經驗 獲得超8個贊

好吧,我想我已經為你編寫了很多代碼。里面有很多錯誤。首先,您根本無法像您或我所做的那樣使用字符串檢查布爾值。布爾值只有真或假。正如我解釋的那樣,這行代碼簡直是愚蠢的錯誤:


isImgClicked.equals("img1")  // This will always be false as isImgClicked is boolean only

現(xiàn)在,這就是我所做的,保持您已經在頁面中嵌入了 jquery。如有任何疑問,請隨時詢問。


        let _img = document.getElementById("img");

        let _img1 = document.getElementById("img1");

        let _img2 = document.getElementById("img2");

        let _btn = document.getElementById("button");


        let isImgClicked = false;

        let isDatePicked = false;


        /* If any event is clicked!!!! */

        $(document).on('click', function(e){

            clickId = e.target.id;           // Get id of clicked element

            pickedDate = $('#datepicker').val();      // Get value of date picked


            // If picked date value is not null, means date is picked

            if(pickedDate.length > 0){

                isDatePicked = true;

            }

            if(clickId == 'img' || clickId == 'img1' || clickId == 'img2'){

                isImgClicked = true;

                selectedImg = clickId;  // Get id of selected image

            }

            if(clickId == 'button')

            {

                if(!isImgClicked)

                {

                    alert("select the Year and Click the car image");

                }

                else 

                {

                    if((selectedImg == "img") && (pickedDate == "2020"))

                        window.location.replace("sample.html");

                    else if((selectedImg == "img") && (pickedDate == "2019"))

                        window.location.replace("sample1.html");

                    else if((selectedImg == "img1") && (pickedDate == "2019"))

                        window.location.replace("sample2.html");

                    else if((selectedImg == "img1") && (pickedDate == "2020"))

                        window.location.replace("sample3.html");

                    else

                        alert("!!!!")

                }

            }

        });

您現(xiàn)在應該能夠解決任何其他問題??赡苡?div id 的混合匹配可供查找。您可以用這個替換提交按鈕的 js 代碼并檢查錯誤。謝謝?。?!


查看完整回答
反對 回復 2022-05-26
?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

您是否添加了 jquery 和 jqueryui 庫?如果沒有,請在代碼的開頭復制以下行,例如 head 部分:


        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> -->

    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

此外,更正這一行:


<div id="img2 "class="swiper-slide"

用這條線:


<div id="img2"class="swiper-slide"


查看完整回答
反對 回復 2022-05-26
  • 2 回答
  • 0 關注
  • 176 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號