HTML
<label class="container"> <input type="radio" name="S1" checked>One</label><br> <label class="container"> <input type="radio" name="S1" >Two</label><br> <label class="container"> <input type="radio" name="S1" >Three</label><br> <label class="container"> <input type="radio" name="S1" >Four</label> <style> .container { cursor: pointer; font-size: 22px; } </style>
<label class="container"> <input type="radio" checked>One</label><br> <label class="container"> <input type="radio" >Two</label><br> <label class="container"> <input type="radio" >Three</label><br> <label class="container"> <input type="radio" >Four</label> <style> .container { cursor: pointer; font-size: 22px; } </style>
<script> var Tag= document.querySelectorAll("input") ; Tag.forEach((round) => { round.addEventListener("click", function() { if(round.value== dp.innerHTML){ round.checked=false ; dp.innerHTML = "?";return } dp.innerHTML = round.value ; }) }) </script>
<script> var Tag= document.querySelectorAll("input") ; Tag.forEach((round) => { round.addEventListener("click", function() { var TT =document.getElementById("dp"+round.value) ; if(TT.style.opacity == 0.3){ TT.style.opacity=1; TT.style.textDecoration = "initial"; } else{ TT.style.opacity=0.3; round.checked=false ; TT.style.textDecoration = "line-through"; } }) }) </script>
<label class="container"> <input type="checkbox" checked="checked">One</label><br> <label class="container"> <input type="checkbox">Two</label><br> <label class="container"> <input type="checkbox">Three</label><br> <label class="container"> <input type="checkbox">Four</label> <style> .container { cursor: pointer; font-size: 22px; } </style>
<label class="container"> <input type="checkbox" checked="checked">One</label> <label class="container"> <input type="checkbox" >Two</label> <label class="container"> <input type="checkbox" >Three</label> <label class="container"> <input type="checkbox" >Four</label> <style> .container { cursor: pointer; padding-left: 30px; font-size: 22px; } </style>
<style> input[type="checkbox"]:checked ~ span{ color: red;} label {cursor:pointer;padding-left: 20px; font-size: 22px;} </style> <label> <input type="checkbox" > <span>One</span></label> <label> <input type="checkbox" > <span>Two</span></label> <label> <input type="checkbox" > <span>Three</span></label> <label> <input type="checkbox" > <span>Four</span></label>
<datalist id="tickmarks"> <option value="0" > 0 </option> <option value="20"> 20 </option> <option value="40"> 40 </option> <option value="60"> 60 </option> <option value="80"> 80 </option> <option value="100">100</option> </datalist> <input type="range" step="10" list="tickmarks" oninput="volumeBox.innerHTML=this.value"> <span id="volumeBox" >50</span> <style> input { width:400px } <style>
<datalist id="tickmarks"> <option value="0" > 0 </option> <option value="20"> 20 </option> <option value="40"> 40 </option> <option value="60"> 60 </option> <option value="80"> 80 </option> <option value="100">100</option> <input type="range" step="10" list="tickmarks" oninput="volumeBox.innerHTML=this.value"> <span id="volumeBox" >50</span> <style> input[type=range]{ writing-mode: bt-lr; /* IE */ -webkit-appearance: slider-vertical; /* WebKit */ width: 30px; height: 300px; } </style>
setInterval() setInterval() method calls a function at specified intervals (in milliseconds). 方法可按照指定的周期(以毫秒計)來調用函數或計算表達式。 setInterval(function, milliseconds, param1, param2, ...) setInterval(function, 毫秒, 參數1, 參數2, ...) clearInterval(myInterval) clearInterval() to stop the time 停止時間 Example: var myInterval=setInterval(........) clearInterval(myInterval)
<p id="demo"></p> <script> var txt="" , ii=0; if(Stop){ clearInterval(myInterval) } var Stop = setInterval(TX, 1000); function TX() { ii++ ; txt += " [RUN " + ii +"] " ; demo.innerHTML = txt ; if(ii > 19){ clearInterval(Stop) ; demo.innerHTML += " clearInterval(Stop)";} } </script> result :
<p id="demo"></p> <script> if(myInterval){ clearInterval(myInterval) } var myInterval = setInterval(myTimer, 1000); function myTimer() { const date = new Date(); demo.innerHTML = date.toLocaleTimeString(); } </script> result :
position 改變物件的位置 sets how an element is positioned in a document position: static | relative | fixed | absolute | sticky static:靜態定位 relative:相對定位 fixed:固定定位 absolute:絕對定位 sticky:黏貼定位
<style> #div1 {position:fixed ; top:10px ; left:10px; } #div2 {position:fixed; top:10px ; right:10px; } #div3 {position:fixed ; bottom:10px ; left:10px; } #div4 {position:absolute ; bottom:10px ; right:10px; } </style>
<div class="outerDiv">outerDiv <div class="innerDiv"> innerDiv</div> </div> <style> .outerDiv { position: relative; } .innerDiv { position: absolute; bottom: 10px; right: 10px; } </style>
<div class="outerDiv">outerDiv <div class="innerDiv"> innerDiv</div> </div> <style> .outerDiv { position: relative ; } .innerDiv { position: sticky; } </style>