The functionality of Draggable and Resizable DIV elements is not functional

I am attempting to incorporate draggable and resizable DIV elements simultaneously using the following resources: http://jqueryui.com/draggable/ http://jqueryui.com/resizable/

It works well when I only use one DIV. I am able to move and resize the DIV.

However, when I have more than one DIV, it doesn't function properly. Resizing one DIV automatically changes the position of another.

How can I resolve this issue?

I have included the following link:

<link rel="stylesheet" type="text/css" href="style.css">

I am using the following JQuery:

<script type="text/javascript">
    $(document).ready(function () {
        $('.yellow').draggable().resizable();
    });

I am using the following CSS:

.yellow {
background-color:#f6921e;
background:rgba(246,146,30,0.3);
border-color:#f6921e; 
width: 50px;
height: 50px;
border-style:solid;
border-width:6px;       
border-radius: 6px;
position:inherit;
position:fixed;

}

I am using the following DIV:

<div class="yellow" style="top:100px">
</div> 

Answer №1

Make sure to utilize the function for each element that matches your specified class

View demo here

jQuery

$.each($('.yellow'),function(index,elem){$(elem).draggable().resizable();;})

CSS

.yellow {
background-color:#f6921e;
background:rgba(246,146,30,0.3);
border-color:#f6921e; 
width: 50px;
height: 50px;
border-style:solid;
border-width:6px;       
border-radius: 6px;
position:inherit;
position:fixed;
}

.red {
background-color:#550000;

border-color:#f6921e; 
width: 50px;
height: 50px;
border-style:solid;
border-width:6px;       
border-radius: 6px;
position:inherit;
position:fixed;
}

HTML

<div class="yellow" style="top:100px">
</div> 
<div class="yellow" style="top:200px">
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

iPhone 3GS and 4 not expanding DIVs by 100%

I've been encountering a significant issue with a div that's set to 100%. It displays properly on desktop screens, but on iPhones, there appears to be a gap on the right side. I've attempted to use the following CSS: body { min-width:980p ...

What is the best way to dynamically convert a lodash object (specifically a filter object) into jQuery's listview component?

After referencing the answer to this topic as my first step, which can be found here, my next goal is to utilize a filter function to retrieve all matching entries from a JSON file based on a search term. The objective is to loop through each match and con ...

Enhancing link functionality with jQuery on a dynamically generated server page

I am facing an issue with my navigation menu that includes dropdowns. On desktop, the parent items need to be clickable as well, which is not a problem. However, for it to be responsive on mobile devices, I need to account for the lack of hover capability. ...

Issues involving JavaScript and jQuery

As a beginner in the world of JS and jQuery, I have encountered a problem that I am seeking assistance with. I am trying to use a script to insert content into a page, but I am facing a roadblock that I can't seem to overcome. Here's the specific ...

Dragging additional events into FullCalendar is disabled after applying a filter to external events

I am encountering an issue while attempting to drag events from the external events box to the fullcalendar. To replicate the problem, you can visit this CodePen: Initially, dragging an external event into the calendar works smoothly. However, after appl ...

Unable to execute the Ajax Delete feature in Laravel

I've been attempting to implement an ajax delete feature in Laravel. Despite my efforts, I'm unable to determine why it's not functioning as expected. There are no errors being displayed, but nothing happens when I click the delete button - ...

Tips for sending additional parameters to an MVC controller without including them in the URL when using the JavaScript window.open method

<a href="#" onclick="openAnchor('<%# DataBinder.Eval(Container.DataItem,"Url") %>', '<%# DataBinder.Eval(Container.DataItem,"infoToSend") %>')"> </a> openAnchor= function (Url, infoToSend) { window.open(Url, ...

Issue detected in FullCalendar: date.getFullYear is not functioning as expected

I am working on adding a line of content to each cell in my calendar, specifically displaying the date in Hebrew next to the regular date number. Currently, I am testing with the standard sample calendar. The code snippet I am using is as follows: dayRe ...

HTML code now launches in the existing electron window rather than opening a new window

<html> <head> <title></title> </head> <input type="button" name="new" id="newmon" value="new"> <button onclick="open1()">monitor 1</button&g ...

Issue with division operation in HTML not functioning

I've been working on a division calculation within an HTML file, but so far I haven't had success using PHP or JavaScript. While {{ property.listprice }} is correctly displaying a number in the HTML file, the other elements are not functioning as ...

Position a div in the center of the page horizontally

Can someone help me with aligning the #main div in the center of the page? I have this code snippet: <div id="main" style=" margin:0 auto; "> <div style="float: left"> <a style="display: block" href="#"><img src="test.gif" ...

Can the serialization of AJAX URL parameters in jQuery be customized?

Is there a way to instruct jQuery or an AJAX call on how to format query string parameters other than writing a custom serializer? I am using a jQuery AJAX call and passing an object with URL parameters var params = {name: 'somename', favColors ...

Tips for connecting a suspended div below a Bootstrap 5 fixed navigation bar

I successfully implemented a sticky navigation using Bootstrap 5, and now I want to add a hanging div (.chat-tag) below the sticky nav for a chat feature. This "hanging tag" should stay attached to the sticky nav as the user scrolls down the page. It&apos ...

Creating a circular gradient in CSS

Does anyone know the steps to create a radial gradient in CSS that will match the background shown below? ...

Removing a table row with jQuery based on the content of a specific cell within the row

I have encountered an issue where I need to delete a specific row in a table that is dynamically generated and does not have any identifiable classes or IDs. The code for the rows looks like this: <tr> <td class="label">Who referred you?&l ...

The images in Bootstrap 5 are displayed individually on separate lines, even though they could easily be accommodated within a

I'm facing an issue with displaying several 50x50 images in a row of 6 columns on my website. Despite the simple code setup, each image appears on its own row, creating the illusion of stacked images rather than a single row. This is the code structu ...

What is the best way to display the most recent data from a sqlite database and incorporate animations for a more engaging

Hi there! I'm looking to retrieve data from an SQLite database and display only the latest entry. Additionally, I'd like to create an animation where scrolling reveals one entry at a time. I would greatly appreciate any assistance with this. Pl ...

What is the method for verifying whether x-iframe-options ALLOW-FROM is supported?

How can I determine if my browser supports X-IFRAME-OPTIONS and X-IFRAME-OPTIONS ALLOW-FROM in the http header, either through client-side or server-side methods? ...

Challenges arise when trying to coordinate scrolling movements between a canvas element and the remaining content on the webpage

I'm currently stuck on a project involving a Three.js canvas with OrbitControls for interactive 3D visualization. The main issue I'm facing is the lack of synchronization between scrolling within the canvas and the rest of the page content. Whil ...

Guide on setting the style attribute in HTML within double quotes (as a String)

I have a straightforward question. I am attempting to include a style attribute in an HTML code that is in string format. I am passing the HTML code as a string through a method, and later I need to apply CSS to it based on certain conditions. I attempted ...