开发者

draggable element color changed back when refreshing

开发者 https://www.devze.com 2023-04-07 15:18 出处:网络
The draggable elememnt color will be changed to #DF2525 when stop dragging. But the color is changed back to original one when page is refresh. I want color won\'t be changed back when refreshing.

The draggable elememnt color will be changed to #DF2525 when stop dragging. But the color is changed back to original one when page is refresh. I want color won't be changed back when refreshing. Is there anyone know solution? Thanks in advance.

$(function() {

        $( "#draggable" ).draggable({

                stop: function(){
                      var position = $(this).position();
                        $(this).css({"color":"#ff00ff","background":"#DF2525"});            
                      }
   开发者_运维问答             });

    });

<div class="demo">

            <div id="draggable" class="ui-widget-content">
                <p>Drag</p>
            </div>
        </div>


If I understand this well, you want the color to be saved? You can use cookies or localStorage for this.


jQuery animation functions only work on the client's side. You can't permanently change the website code using it. If you want to interact with server side, think of using AJAX and some data aquisition.

0

精彩评论

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

关注公众号