62,046
社区成员
发帖
与我相关
我的任务
分享
<body>
<form id="form1" runat="server" autocomplete="on">
<div id="dv1">
<asp:Label ID="Label1" runat="server" Text="123123"></asp:Label>
</div>
</form>
</body>
<script>
alert($('#<%=Label1.ClientID%>').text());
</script>
主要还是$('#<%=Label1.ClientID%>')<body>
<form id="form1" runat="server" autocomplete="on">
<div id="dv1">
<span id="sp">123</span>
</div>
<input type="button" id="edit" value="edit"/>
<input type="button" id="print" value="print"/>
</form>
</body>
<script>
//修改span的值
$('#edit').click(function () {
$('#sp').html('hahah123');
})
//弹出修改后的值 hahah123
$('#print').click(function () {
var s = $('#sp');
alert(s.html())
})
</script>
$conter.text(....)
来赋“值”的代码了嘛。
其实这已经不是 value 了,说“值”有点歧义。<span>只有文本,没有值。
//html
票数:<span id="counter"></span>
<asp:HiddenField runat="server" ID="hidCounter" />
//JS
$('<%=hidCounter.ClientID %>').val($('#counter').val());
int counter = Int32.TryParse(hidCounter.Value,out counter)?Convert.ToInt32(hidCounter.Value):0;
<asp:Hidden id="hd_xxx" runat="server">
应该差不多是这样吧,vs工具栏有的