Use jQuery UI draggable to create a clone with a shadow effect

Attempting to replicate this:

This is what I have for the draggable element:

$( function() {
    $('#sidebar .question-constructor').draggable({
        connectToSortable:'#preview',
        scroll: false,
        helper : 'clone',
        cursorAt: { top: 56, left: 200 } 
    });
});

and my div:

<div class="question-constructor" style="border-style:solid; border-width:5px;">
    <label for="textbox" style="display: inline-block;" >Question: </label>
    <input id="textbox" type="text" />
</div>

My current result looks like this:

I'm not quite achieving my desired outcome yet. However, at the moment, I want to learn how to add a shadow to the clone of the draggable element similar to my target image.

UPDATE:

I attempted using this code snippet:

$('.question-constructor').animate({ boxShadow : "0 0 5px 3px rgba(100,100,200,0.4)" });

I placed it outside the draggable selector but it's still not producing the desired effect.

Answer №1

Try this alternative method:

$('.question-constructor').changeStyle({ boxShadow : "0 0 5px 3px rgba(50,100,150,0.6)" });

Replace it with:

$('.question-constructor').updateStyle('boxShadow','4px 2px 17px 5px #555');

Answer №2

Give it a shot

$(function () {
    $('.question-builder').draggable({
        connectToSortable: '#preview',
        scroll: false,
        helper: 'clone',
        start: function (e, ui) {
            $(ui.helper).css('boxShadow', '0 0 5px 3px rgba(100,100,200,0.4)'); //modify css 
        },
        cursorAt: {
            top: 56,
            left: 200
        }
    });
});

Demo available at http://jsfiddle.net/code_samples/ndb8G/

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

Difficulty arises when trying to add various text fields to a collection

Lately, I've been making modifications to the Meteor1.3+React Todos app to familiarize myself with the basics, and I must say, it's been a smooth ride so far. However, I have encountered a roadblock. I want to incorporate an additional text field ...

What is the method for determining profit as a percentage?

I need some help with a basic question. I have two variables, 'a' and 'b'. Variable A represents the money I receive from a customer, while variable B represents the money I will pay to a carrier. For example, if I receive $1000 from a ...

Upon resolving cross-origin resource sharing issues, an AJAX call from a virtual server resulted in a HTTP 500 error, indicating that the

Trying to send a POST request to a Linux server from a Windows 7 virtual machine using VirtualBox was initially met with CORS issues. To resolve this, I installed the 'Allow-Control-Allow-Origin:' Chrome extension '*'. The CORS problem ...

Incorporating a Bootstrap input group within a <td> element of a table

Encountering an issue when attempting to include a bootstrap input-group-addon with the input field nested inside a <td> tag within a table. Once all necessary classes are applied, there appears to be some spacing between the sign and the input field ...

Modify the href value by matching it with the parent div attribute

I am working on an HTML project <div class="1" style="" title="NeedthisText TextIDontneed"> <div class="2> <div class="3"> <a target="_blank" href="/NeedToChange/DispForm.aspx?ID=1"></a> </div> </div> &l ...

Puppeteer App Error: An error has been detected on the client side

I am facing an issue using Puppeteer with NEXT.JS while attempting to capture a screenshot. Everything runs smoothly on localhost, but in production, the captured image comes back with the following error message: Application error - a client-side exceptio ...

Organizing the website's files and extensions

Transitioning from programming desktop applications to websites can be overwhelming, especially when dealing with multiple languages and extensions like JavaScript, CSS, JSON, Bootstrap, Ajax, and PHP all at once. How do you effectively juggle these diff ...

Error in SO Embed Snippet Fiddle due to Bootstrap 4 JS Issue

Just wondering, any idea why the bootstrap 4 js is throwing this error: https://i.sstatic.net/J4Iq4.png when trying to embed the snippet? (No errors in the external Fiddle) Added tether.js but no luck (kept it commented). Switched to jQuery 2.2.1 on th ...

Attempting to create a login and registration form

Hello, I am attempting to create a form that can generate new user accounts and passwords. These values should be stored from the input tag when the user clicks on the register button. Unfortunately, I am encountering an issue where clicking the register ...

Unable to delete React element by ID as it is undefined

Having some trouble deleting an item by ID with React. Despite the backend routes functioning properly (node and postgresql), every attempt to delete an item results in it reappearing upon page refresh. The command line indicates that the item being delete ...

Unusual behavior of PHP echo when inserting into an HTML value attribute

Let's dive right into the problem. I have a database entry that is a string in the column name1 and it looks something like this: COMPANYNAME DIVADAY The key characteristic of this string is that it is mostly a combination of two or more words separ ...

AngularJS default ngOptions for parent and child models

Is there a way to set default ngOptions through parent/child models? Here, the OP demonstrates using ngOptions with parent/child relationships. template <select ng-model="x.site" ng-options="s.site for s in data"></select> <select ng-mode ...

What emerging patterns can be observed in the security of client-side coding within the realm of web development

Keeping up with the constant flow of new frameworks and technologies can be overwhelming. One area that particularly interests me is client-side frameworks, such as AngularJS, Backbone, Knockout, jsviews, knockback, SPA... These are currently among the mos ...

Tips for overriding a CSS class without impacting other classes sharing the same name

Within a page filled with various widgets, I am facing an issue where I need to override the container class for a specific widget. However, the problem is that all widgets with the same class name are being impacted. Attached below is a screenshot from in ...

The error states that the type '() => string | JSX.Element' cannot be assigned to the type 'FC<{}>'

Can someone help me with this error I'm encountering? I am fairly new to typescript, so I assume it has something to do with that. Below is the code snippet in question: Any guidance would be greatly appreciated. const Pizzas: React.FC = () => { ...

Using a jQuery if statement to target a particular div and apply custom CSS styling

I have encountered a unique challenge that I am struggling to solve. Imagine I have a 3x3 table created using div elements, and one of the cells has a background color of #999. My goal is to use jQuery to check if a specific cell has this background color, ...

obtain the selected value from the radio button

While working on the server side, I dynamically created radio buttons with the following code: RadioButton button1 = new RadioButton(); button1.ID = question.Name + "_Radio1"; button1.Text = "Yes"; RadioButton button2 = new RadioButton(); button2.ID = qu ...

Struggles with fading in and out

I'm currently working on enhancing a pure CSS rollover with a smooth transition/fade effect, but I'm encountering some difficulties in achieving the desired outcome. The concept involves displaying a new div called "online-hover" when hovering o ...

Issues with <select> element width inconsistency in Internet Explorer compared to other browsers

I am working with three select boxes as part of my project. <div style='float: left; padding-right: 10px;'> <select size="10" name="company_id"> // numerous options available </select> </div> <div styl ...

Troubleshooting CSS transition issues on ASP.NET Web Forms

Is there a way to make CSS3 transitions work in a .aspx page? I prefer Web Forms for designing forms and any suggestions would be helpful. The following is the code snippet from the .aspx page: <%@ Page Title="" Language="C#" MasterPageFile="~/Sit ...