xpanta xpanta - 9 months ago 29
Javascript Question

modify contents of div while dragging with jquery ui draggable

I have a draggable div (jquery ui draggable) which contains mainly text. Can I change the contents of the div while dragging?

(actually, I want to make it a smaller and nicer div)


Try this out: http://jsfiddle.net/6JtMp/

Here's the code:

    #draggable { width: 150px; height: 150px; padding: 0.5em; background-color: green; }
    $(function() {
        $( "#draggable" ).draggable({
            start: function(event, ui) { $(this).css("height",10); },
            stop: function(event, ui) { $(this).css("height",150); }        

<div class="demo">

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

</div><!-- End demo -->