且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何存储jQuery函数的结果并将其显示在其他页面上

更新时间:2023-12-03 08:58:28

如果你不想使用AJAX / PHP那么您可以使用HTML5中引入的浏览器的localStorage或sessionStorage,如下所示:

If you don't want to use AJAX/PHP then you can use the browser's localStorage or sessionStorage as introduced in HTML5, as:

如果您的结果存储在 id =结果的元素中
然后你可以将它存储在locaStorage中:

If your result is stored in an element with id= "results" then you can store it in locaStorage as:

localStorage.setItem('titles', $('#results').text()); 

并获取任何其他页面上的项目使用:

and to fetch the item on any other page use:

var myItem = localStorage.getItem('titles');

有关本地和会话存储的更多信息,请访问:
本地存储

会话存储

More about local and session storage here:
Local Storage
Session Storage