jQuery-文本框內容顯示在頁面
阿新 • • 發佈:2018-11-11
lang utf oct UNC text utf-8 input 內容 jquery
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="jquery-1.11.3.js"></script> <script> window.onload = function(){ $("#btn").click(function(){ //1、獲取 uname 的值 var uname = $("#uname").val(); //2、將uname的值顯示在#show中 $("#show").html(uname); //3、設置#show的css樣式 $("#show").css({ "font-size":"32px", "color":"red", "background":"yellow", "font-weight":"bold" }); }); } </script> </head> <body> <p> 用戶名: <input type="text" id="uname"> <button id="btn">顯示</button> </p> <div id="show"></div> </body> </html>
jQuery-文本框內容顯示在頁面