2016-03-15 229 views
0

如何使用jQuery制作本地网络存储,当访问我的网络时,数字会上升,如下面的示例所示?jQuery本地网络存储

<!DOCTYPE HTML> 

<script type="text/javascript"> 
    if(localStorage.hits){ 
     localStorage.hits = Number(localStorage.hits) +1; 
    } 

    else{ 
     localStorage.hits = 1; 
    } 
    document.write("Total Hits :" + localStorage.hits); 
    </script> 

    <p>Refresh the page to increase number of hits.</p> 
    <p>Close the window and open it again and check the result.</p> 

回答

0

jQuery的不提供任何API来访问本地存储(见the docs)。

只需使用localStorage API,你已经在做什么。