<html>
<body>
<textarea id="textarea">在这里直接书写,即为赋值</textarea>
</body>
</html>
<script type="text/javascript">
var tObj = document.getElementById('textarea')
tObj.value = '也可以通过JS赋值'
</script>
需要准备的材料分别有:电脑、html编辑器、浏览器。
1、首先,打开html编辑器,新建html文件,例如:index.html,填写问题基础代码。
2、在index.html中的<script>标签,输入js代码:$('#txt').val('测试内容')。
3、浏览器运行index.html页面,此时会发现html中的text被成功用js赋值了“测试内容”的文本。
<input id='hidetext' name="hidetext" type="hidden" value=<% =(string)Session.getValue("username") %>/>//直接通过session赋值document.getElementById('hidetext').value="赋值"//js赋值
$("#hidetext").val("赋值")//jquery写法.
以上是html控件赋值方法
<input id="hidetext" type="hidden" runat="server"/>
hidetext.Text ="赋值"//cs后台复制
<asp:HiddenField ID="HiddenField1" runat="server" />
hidetext.value="赋值"//cs后台复制
以上是服务器端控件赋值方法(服务器端也可以使用js,jquery进行赋值)