Скрипт-счётчик кликов. Как запоминать клики?
Такой вот скрипт. По нажатия увеличивается значение на 1, но при обновлении страницы значение не сохраняется. Как сохранять его?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> .votecard { background: url([url]http://psv4.vk.me/c423017/u99861193/docs/2d58ae011f25/sprite.png?extra=DQOw7jDFvKnOmx9Ta0_gSsrZSJ5UDZC1JB9jFUVy1OEdorJDEJ5Jox6LD-7fIX8xxsQyBaITc0LeuEOn_B3ki9JIYlQMLmIB[/url]) no-repeat 0 0; padding: 4px; width: 63px; height: 43px; text-align: center; } .votecard div { position: relative; overflow: hidden; width: 63px; height: 43px; } .votecard em { display: block; position: relative; width: 63px; height: 33px; padding: 6px 0 6px 0; font: normal 24px/24px "Helvetica Neue","Helvetica","Arial",Sans-serif; color: #45453f; } .votecard strong { font-weight: bold; } .votecard span { font-size: 10px; line-height: 10px; display: block; color: #9a9a94; } a.voteaction { margin: 0 0 0 3px; display: block; text-indent: -9999px; width: 71px; height: 21px; background: url([url]http://psv4.vk.me/c423017/u99861193/docs/2d58ae011f25/sprite.png?extra=DQOw7jDFvKnOmx9Ta0_gSsrZSJ5UDZC1JB9jFUVy1OEdorJDEJ5Jox6LD-7fIX8xxsQyBaITc0LeuEOn_B3ki9JIYlQMLmIB[/url]) no-repeat -3px -75px; } a.voteaction:hover { outline: none; background-position: -3px -54px; } a.voted, a.voted:hover { outline: none; background-position: -3px -96px; cursor: default; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { /* create a node for the flip-to number */ $(".votecard em").clone().appendTo(".votecard div"); /* increment that by 1 */ var node = $(".votecard em:last strong") node.text(parseInt(node.text())+1); function flip(obj) { obj.prev().find("em").animate({ top: '-=45' }, 200); obj.toggleClass("voted",true); } $('.voteaction').bind({ click: function(event) { event.preventDefault() }, mouseup: function() { flip($(this)); $(this).unbind('mouseup'); } }); }); </script> </head> <body> <div class="votecard"> <div> <em><strong>0</strong><span>Flips</span></em> </div> </div> <a class="voteaction" href="">Flippit</a> </body> </html> |
[JS]
сохранить localStorage.setItem('num_click', index) var num_click = +localStorage.getItem('num_click'); [JS] |
Часовой пояс GMT +3, время: 21:28. |