开发者

How to add cookies to a drag and drop div

开发者 https://www.devze.com 2023-02-18 20:57 出处:网络
Hel开发者_如何学Clo i have added a drop and drop feature to my site See Here and as i am a beginner i don\'t know anything about adding cookies to a page or a div, i would like to have a save button w

Hel开发者_如何学Clo i have added a drop and drop feature to my site See Here and as i am a beginner i don't know anything about adding cookies to a page or a div, i would like to have a save button which will save the position of the div so that when a user returns to a page it will be where they left it, any help will be appreciated,


Seems you're using jQuery.

Include jquery.cookie.js. You can now set cookies like $.cookie('position_x', 123) and get them like $.cookie('position_x').

The drag-and-drop library should have some callback that is run when you stop dragging. In that callback, save the x and y position away in separate cookies (to keep things simple).

When the page loads, check for those cookies and use the values to position the element.

0

精彩评论

暂无评论...
验证码 换一张
取 消