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

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

如何取與 fields[m].validationMessage 相鄰元素label.innerhtml的值

如何取與 fields[m].validationMessage 相鄰元素label.innerhtml的值

叢從綠草 2018-07-20 19:39:03
<style>.oneline {? ? line-height: 1.5;? ? margin: 10px auto;}.oneline label {? ? width: 100px;? ? text-indent: 15px;? ? font-size: 14px;? ? font-family: "Microsoft Yahei";? ? display: inline-block;}.oneline .sinput {? ? width: 60%;? ? height: 30px;? ? border-radius: 6px;? ? border: 1px solid #e2e2e2;}.oneline input[type="submit"] {? ? margin-left: 20px;? ? width: 80px;? ? height: 30px;? ? border: 0;? ? background-color: #5899d0;? ? color: #fff;? ? font-size: 14px;? ? border-radius: 6px;}.error-messages {? ? color: red;}</style><body>? ? <form id="forms">? ? ? ? <div class="oneline">? ? ? ? ? ? <label for="name">用戶名:</label>? ? ? ? ? ? <input id="name" class="sinput" name="name" type="text" required>? ? ? ? </div>? ? ? ? <div class="oneline">? ? ? ? ? ? <label for="email">Email:</label>? ? ? ? ? ? <input id="email" class="sinput" name="email" type="email" required>? ? ? ? </div>? ? ? ? <div class="oneline">? ? ? ? ? ? <input type="submit" id="submits" value="提交">? ? ? ? </div>? ? </form>? ? <script>? ? function replaceValidationUI(form) {? ? ? ? form.addEventListener("invalid", function(event) {? ? ? ? ? ? event.preventDefault();? ? ? ? }, true);? ? ? ? form.addEventListener("submit", function(event) {? ? ? ? ? ? if (!this.checkValidity()) {? ? ? ? ? ? ? ? event.preventDefault();? ? ? ? ? ? }? ? ? ? },true);? ? ? ? //此處寫(xiě)代碼? ? ? ? var submits = document.getElementById('submits'),? ? ? ? ? ? label = document.getElementsByTagName('label');? ? ? ? submits.addEventListener('click',function(event){? ? ? ? ? ? var fields = form.querySelectorAll(':invalid'),? ? ? ? ? ? ? ? error = form.querySelectorAll('.error-messages'),? ? ? ? ? ? ? ? parent;? ? ? ? ? ? for(var i = 0;i<error.length;i++){? ? ? ? ? ? ? ? error[i].parentNode.removeChild(error[i]);? ? ? ? ? ? };? ? ? ? ? ? for(var m = 0;m<label.length;m++){? ? ? ? ? ? ? ? parent = label[m].parentNode.parentNode;? ? ? ? ? ? ? ? parent.insertAdjacentHTML("afterBegin","<div class='error-messages'><ul><li>"+label[m].innerText+fields[m].validationMessage+"</li></ul></div>");? ? ? ? ? ? };? ? ? ? ? ? if (fields.length > 0) {? ? ? ? ? ? ? ? fields[0].focus();? ? ? ? ? ? };? ? ? ? },true)? ? }? ? var forms = document.getElementById("forms");? ? replaceValidationUI(forms);? ? </script></body>誰(shuí)能告訴我,如何取與 fields[m].validationMessage ?相鄰元素label.innerhtml的值; 想不通,弄了 一下午,是不是腦子不好使。。。 還是不需要取這個(gè)label值??
查看完整描述

目前暫無(wú)任何回答

  • 0 回答
  • 0 關(guān)注
  • 1058 瀏覽
慕課專欄
更多

添加回答

舉報(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)