Javascript 如果用户刷新页面,是否可以维护jquery事件显示的内容?
在我的网页中,我通过使用jquery单击导航菜单来更改内容(如gmail)。举个例子Javascript 如果用户刷新页面,是否可以维护jquery事件显示的内容?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,在我的网页中,我通过使用jquery单击导航菜单来更改内容(如gmail)。举个例子 <p> I have a classifieds website, and on the page where ads are showed, I am creating a "Send a tip to a friend" form... So anybody who wants can send a tip of the ad to some friends email
<p>
I have a classifieds website, and on the page where ads are showed,
I am creating a "Send a tip to a friend" form... So anybody who wants can send a tip of the ad to some friends email-adress.
I am guessing the form must be submitted to a php page right? When submitting the form, the page gets reloaded... I don't want that... Is there any way to make it not reload and still send the mail? Preferrably without ajax or jquery... Thanks
</p>
<button id="chg">
Change content
</button>
我想要的要点是,在单击更改内容
按钮后,p
元素中的文本现在更改为新内容在这里….
此时,如果用户重新加载页面,我只想显示已更改的内容,如此处有新内容….
。不是用html
编写的文本(段落)
我已经尽力了。但我不能解决这个问题。所以,我非常感谢你的建议
$(document).ready(function(){
if (sessionStorage.getItem("newContent")) {
// Restore the contents
$("p").html(sessionStorage.getItem("newContent"));
}
$("#chg").click(function(){
var newCont = "New contents are here........";
$("p").html(newCont);
sessionStorage.setItem("newContent", newCont);
});
});
你可以试试@anu,你能发表评论回答吗?
$(document).ready(function(){
if (sessionStorage.getItem("newContent")) {
// Restore the contents
$("p").html(sessionStorage.getItem("newContent"));
}
$("#chg").click(function(){
var newCont = "New contents are here........";
$("p").html(newCont);
sessionStorage.setItem("newContent", newCont);
});
});