[英]Can I store entire label to sessionStorage
Hi all I would like to access label and set the text for that label in another form, so I tried as follows 大家好,我想访问标签并以另一种形式设置该标签的文本,所以我尝试了如下
function ShowNewPage() {
sessionStorage.setItem("total", $('#<%= lblHidden %>'));
modalWin.ShowURL('test.html', 300, 400, 'Second From', null, callbackFunctionArray);
}
But I am not able to access the label it in another form when I use the following sessionStorage.getItem("total")
so can some one help me 但是当我使用以下sessionStorage.getItem("total")
时,我无法以另一种形式访问标签,因此有人可以帮助我
Web storage only stores strings so you can't store a jQuery object or dom element directly Web存储仅存储字符串,因此您不能直接存储jQuery对象或dom元素
Just store the selector that references that object and you can wrap the stored selector in $()
when you need to use it 只需存储引用该对象的选择器,即可在需要使用时将存储的选择器包装在$()
。
sessionStorage.setItem("total", '#<%= lblHidden %>');
Then to use: 然后使用:
var selector = sessionStorage.getItem("total");
alert($(selector).attr('id'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.