劉任昌JavaScript,input,text,getElementById.

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上課影片

留言

  1. https://xdrcfvghyujiok8945656.blogspot.com/2023/01/javascriptinputtextgetelementbyid.html

    回覆刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. https://jdoifjopq1264.blogspot.com/2023/01/blog-post.html

    回覆刪除
  4. https://yuzcc28.blogspot.com/2023/01/javascriptinputtextgetelementbyid.html

    回覆刪除
  5. https://rtytrdtfg.blogspot.com/2023/01/javajavascriptinputtextbuttongetvalueby.html

    回覆刪除
  6. https://d11150115.blogspot.com/2023/01/javascannerlengthcharat.html

    回覆刪除
  7. https://wxxx17.blogspot.com/2023/01/javascriptinputtextgetelementbyid.html

    回覆刪除
  8. https://643gjeytfru4312.blogspot.com/2023/01/javajavascriptinputtextbuttongetvalueby.html

    回覆刪除
  9. https://d11150116.blogspot.com/2023/01/javascannerlengthcharat.html

    回覆刪除
  10. https://tgyhjikolujik2554.blogspot.com/2023/01/h1bordersolid-5px-red-javascript.html

    回覆刪除
  11. https://d11150113.blogspot.com/2023/01/javascript-function-f-var-document.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌對照Python與JavaScript指令

劉任昌Python集合set清單list元組tuple字典dictionary

劉任昌python, input, str, float