xpanta xpanta - 2 years ago 93
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)

Answer Source

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 -->
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download