Target
Target

Reputation: 199

Drag and resize div

I found the follwing code, but original code used ID but when i use class its not working? As i use the same class name for different boxes which are drag-gable and re sizable.

 $(function() {
            var a = $(".texteditorInitial");
            var b = $('#siteGroup');
            a.draggable({
            drag: function() {
                    if (a.position().top > b.height() - a.height()) {
                        b.height(b.height() + 10);
                    }
                    if (a.position().top < b.height() - a.height()) {
                        b.height(b.height() - 1);
                    }
                }
            });
            var c = $(".title_bar");
            var d = $('#siteGroup');
                c.resizable({
                resize: function() {

                    if (c.offset().top > d.height() - c.height()) {
                        d.height(d.height() + 10);
                    }
                    if (c.offset().top < d.height() - c.height()) {
                        d.height(d.height() - 1);
                    }
                }
            });

        });

please help.

Upvotes: 0

Views: 111

Answers (1)

Arunkumar Vasudevan
Arunkumar Vasudevan

Reputation: 5330

i think it works

Check This Fiddle

<div class="texteditorInitial"></div>
<div id="siteGroup"></div>
<div class="title_bar"></div>

Upvotes: 2

Related Questions