劉任昌JavaScript輸出與輸入的程式碼
JavaScript輸出與輸入的程式碼 輸入字串: JavaScript程式碼 <p>輸入字串:<input type="text" len="50" id="in"></p> <p><input type="button" value="執行JavaScript" onclick="f()"></p> <p id="out"></p> <script> function f(){ var a = document.getElementById("in").value;/*取得id=in的文字*/ var b = "原字串: "+a+"<br>長度是:"+a.length+"<br>反串是: "; var c = ""; for (var i = 0; i < a.length; i++) c = a.slice(i,i+1) + c; b = b +"<font size=7>" +c + "</font>"; document.getElementById("out").innerHTML = b;/*輸出html指令*/ } </script> 196影片