获取设置input标签的值
<input class="form-control" type="text" id="username" name="username" placeholder="" value="初始值" onblur="keyblurfun()"> <input class="form-control" type="text" id="username" name="username" placeholder="" value="{{ user.get('userid','') }}"> <script> var username = $("#username").val(); // 获取 id 为 username 的标签的值。 console.log(username); $("#username").val("hello world"); // 设置 id 为 username 的标签的值 console.log($("#username").val()); </script>
获取设置textarea标签的值
<textarea class="form-control" id="brief" name="brief" cols=10 rows=6 placeholder="">Java</textarea> <textarea class="form-control" id="brief" name="brief" cols=10 rows=6 placeholder="">{{study.get('brief','')}}</textarea> <script> var content= $("#brief").val(); // 获取 textarea 标签的值 console.log(content); // Java $("#brief").val("Python"); // 设置 textarea 标签的值 console.log($("#brief").val()); // Python </script>