我在div中有一个文本“Hello world”,我想在更新面板刷新后选择,选择在定时器间隔后关闭,如何在页面刷新后保持文本选择一段时间。
<i>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<div id="sort-item">
Hello world
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
</asp:Timer>
</form>
</i>
答案 0 :(得分:0)
使用html localstorage:
$(document).ready(function(){
var id = $("#sort-item").text();
if(localStorage.getItem("sort-item-id") == ""){
localStorage.setItem("sort-item-id", id);
}else{
$("#sort-item").text(localStorage.getItem("sort-item-id"));
}
});