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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

判斷?。?!如何在JS里面通過value值判斷當(dāng)前選擇的按鈕,并打印出來(lái)

判斷?。?!如何在JS里面通過value值判斷當(dāng)前選擇的按鈕,并打印出來(lái)

慕斯王 2019-04-18 18:15:49
1.當(dāng)點(diǎn)擊“長(zhǎng)期有效”時(shí),打印出“長(zhǎng)期有效”。2.當(dāng)點(diǎn)擊自定義后,顯示時(shí)間彈出框并選擇時(shí)間后,打印出當(dāng)前日期。(這邊要判斷是否選擇了日期,沒有選擇日期的話要alert選擇時(shí)間)HTML代碼<div class="col-sm-10"> <input type="radio" name="inlineRadioOptions1" id="inlineRadio1" value="option1" class="dateChoose" value=" 0">  <label for="inlineRadio1">長(zhǎng)期有效</label> <input type="radio" name="inlineRadioOptions1" id="inlineRadio2" value="option2" class="dateChoose others" value= "1">  <label for="inlineRadio2">自定義</label> <input type="date" name="inlineDateChoose" class="form-control dateJump" id="datetimeInput" value="" placeholder="" style="width: 165px"> <button id="btn" class="btn">點(diǎn)我</button> </div>顯示/隱藏效果代碼<style>     .others ~ input[type='date'] {         display:none;     }     .others:checked ~ input[type='date'] {         display:inline;     }     #date:before {         content:"before";     }     #date::before {         content:"before";     }     </style>顯示/隱藏JS效果代碼$(function(){         $(".dateChoose").click(function(){             $(this).siblings().attr("checked",false);             $(this).attr("checked",true);             if($(this).attr("class").indexOf('others')>=0){                 $(this).siblings('.dateJump').show();             }             else{                 $(".others").siblings('.dateJump').hide();             }         });     })JS判斷代碼?。。?!var v1 = document.getElementById('inlineRadio1');       var v2 = document.getElementById('inlineRadio2');       if(v1.value == '0'){           times = "長(zhǎng)期有效";           console.log(times);           return times;       }       else {           if(v2.value == '1'){               times = $(".dateJump");               console.log(times);               return times;           }           else {               alert("請(qǐng)選擇截止時(shí)間");               return times;           }       }             $('.btn').click(function () {         console.log(times.val());     })//打印出times的值為時(shí)間或者“長(zhǎng)期有效”效果圖選擇長(zhǎng)期有效時(shí)選擇自定義并選擇時(shí)間各位大佬,主要是判斷這邊的代碼不知道怎么寫,我是設(shè)置了他value的值,從判斷value的值來(lái)判斷點(diǎn)選了那個(gè)選項(xiàng)?。?!最終打印出的結(jié)果times的值為時(shí)間或者“長(zhǎng)期有效”?。。?
查看完整描述

3 回答

?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊

已解決,換了其他的方式后可以成功!


查看完整回答
反對(duì) 回復(fù) 2019-05-12
?
阿晨1998

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊

var v1 = document.getElementById('inlineRadio1');
var v2 = document.getElementById('inlineRadio2');
$('.btn').click(function () {
    var times = '請(qǐng)選擇截止時(shí)間';
    if (v1.checked == true) {
        times = "長(zhǎng)期有效";
    } else if (v2.checked == true) {
        times = $(".dateJump").val();
        if (!times||times == "") {
            times = '請(qǐng)選擇截止時(shí)間';
        }
    }
    console.log(v1.checked, v2.checked, times);
    alert(times)
}) //打印出times的值為時(shí)間或者“長(zhǎng)期有效”


查看完整回答
反對(duì) 回復(fù) 2019-05-12
?
尚方寶劍之說(shuō)

TA貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊

document.getelementbyid("inlineRadio1").innerText應(yīng)該能讀取它的文本值


查看完整回答
反對(duì) 回復(fù) 2019-05-12
  • 3 回答
  • 0 關(guān)注
  • 772 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)