I have a div which is resizable and now I want to edit a cookie when this box is resized/when the user finished resizing. (I have the cookie plugin)
How can I do this?
PS: I have multiple .div
's with different id's.
<div class="div" id="div1"></div>
<div class="div" id="div2"></div>
My Code which doesn't work (it doesn't save the cookie)
$( ".div" ).resizable({
handles: \'s\',
onResize: function(size) {
$.cookie("div_height", this.height);
}
});
Use this code
$( ".div" ).resizable({
handles: \'s\',
stop: function(e,ui) {
$.cookie("div_height", ui.size.height);
}
});
Here is a working js fiddle to capture the resize event, having another example, but it perfectly suitable for you: http://jsfiddle.net/byrgv6j4/1/
$('.resizable').resizable({
aspectRatio: true,
handles: 'ne, se, sw, nw',
resize: function(e, ui) {
//console.log(e);
//console.log(ui);
console.log(ui.size.height);
}
});
You must get the ui.size.height
if you want to get the height of the current state of the element.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.