display div width&height + div x&y coordinates
hi, im new to JQuery, i found 2 tutorials which i followed ut now im a bit stuck.
I have x amount of draggable & resizable divs, they work as i want them to, im outputing the coordinates of each div in a textfield. My problem is that the textfield only displays coordinates when a div is CLICKED, so when holding the mouseBtn and draging a div
around then releasing the mouseBtn the coordinates aren't displayed in the textfield.
I tried to set 'mouseup' instead of 'click' but then the divs are being dragged around all the time even tho you released the mouseBtn.
The second thing is that i want to output the size of the div in another textfield, so when a div is resized the new size of that div should be displayed in the textfield.
- <script>
- $('#resizeDiv, #resizeDiv2, ,#resizeDiv3')
- .draggable()
- .resizable({
-
- minHeight: 150,
- minWidth: 200
- });
- </script>
- <script>
-
- $("*", document.body).click(function (e) {
- var offset = $(this).offset();
- e.stopPropagation();
- $("#result").text(this.id + " coords ( " + offset.left + ", " +
- offset.top + " )");
- });
- </script>
for the size i tried to work with
- function showWidth(ele, w) {
- $("div").text("The width for the " + ele +
- " is " + w + "px.");
- }
- $('#test').click(function () {
- showWidth("paragraph", $(this).width());
- });
i want to send both size and x&y of each div to a database, so any suggestions that will improve/help my process are very much welcome!
Greets