Move a button using jQueryUI

HTML code resides below

<!doctype html>
<html>
    <head>
        <title>jQuery UI: Alphabet Matcher</title>

        <link href="css/normalize.css" rel="stylesheet">
        <link href="matchalphabate.css" rel="stylesheet">

        <!-- jQuery UI CSS -->
        <link href="js/jquery-ui-1.12.1/jquery-ui.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="container">
            <h1>Drag and Arrange Alphabets</h1>

            <div id="dragable">
                <h3>Alphabet Table</h3>

                <button class="b">A</button>
                <button class="b">B</button>
                ...
            </div>

            <h4>Arrange now</h4>

            <ul id="sortableToo">
                <li>Other Item A</li>
                <li>Other Item B</li>
                ...
            </ul>

            <a href="" class="button">Submit</a>
            <a href="" class="button alt-button"> Reset</a>
        </div>
        <!-- .container -->

        <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

        <script>
            window.jQuery || document.write('<script src="jquery-3.3.1.js"><\script>');
        </script>
        <script src="js/jquery-ui-1.12.1/jquery-ui.min.js"></script>    
        <script src="js/matchalphabate.js"></script>
    </body>
</html>

CSS code is as follows

.container {
    position: relative;
    width:1000px;
    ...
}
...

jQuery implementation below

$(function (){
    $(".b").draggable();
});

To arrange the alphabet from A-Z, drag and drop them on the table. Upon fully arranging them, a message will be displayed when the submit button is clicked, or you can reset the arrangement to its previous state.

If buttons are not dragging alphabet A-Z and failing to arrange correctly, please provide information on how to successfully rearrange them upon clicking the submit button.

Answer №1

It is not possible to drag the button, but you can create a div that is draggable for each button.

Here's an example:

$( function() {
    $( ".draggable" ).draggable();
  } );
.draggable { width:300px;}
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>

  </script>
</head>
<body>
 
  <div  class="draggable ui-widget-content">
   <button>notDraggable</button>
   <button>notDraggable</button>
   <button>notDraggable</button>
   but draggable div
  </div>
  <div  class="draggable ui-widget-content">
   <button>notDraggable</button>
   but draggable div
  </div>
  <div  class="draggable ui-widget-content">
   <button>notDraggable</button>
   but draggable div
  </div>
 
 
</body>
</html>

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

Expanding the outer div with Jquery's append() function to accommodate the inner div elements perfectly

I am facing an issue where my outer div does not expand automatically to fit the elements I append inside it using jQuery. The structure of my div is as follows: <div class="well" id='expand'> <div class="container"> < ...

There was an issue with the RouteHandler function at line 21 in the ./.cache/root.js

Attempting to create a Gatsby project without using the CLI to gain insight into how the CLI-generated components work. However, encountering the following runtime error popup in the browser: Unhandled Runtime Error One unhandled runtime error has been de ...

What is the best way to place a slider side by side with forms while utilizing Bootstrap?

I am looking to display a sample app screen inline with a form on my website. I have attempted to use the following code in the slider's CSS: display: inline-block; overflow: hidden; white-space: no-wrap; Unfortunately, this has not been successful ...

Rewriting a JSON tree structure in NodeJS

Exploring a new method in comparison to my previous post. The situation involves a JSON structure as follows: var data = { "tree": { "id": "99842", "label": "Bill", "children": [ { "id": "27878", ...

Transferring JavaScript variables to PHP

I am trying to send a JavaScript variable to PHP. Here is the code I am using: function sub(uid){ window.location.href='<?php echo $urlp -> certificationceap(uid) ;?>'; However, I am encountering an issue. ...

Utilize the v-if directive with nested object properties for dynamic conditional rendering

I need to verify if the item object has a property called 'url' set. If it's not present, I would like to display a placeholder image. Here is an example of what I want to achieve: <img v-if="item.relationships.main ...

What is the method to find the biggest number in an array?

I'm encountering challenges with this piece of code and it seems impossible to locate a resolution. Take a look at the code snippet: function findHighestValue(numbers) {} const highestValue = findHighestValue([1, 9, 5]); console.log(highestValue); ...

Try out a Vue.js Plugin - A Comprehensive Guide

Currently, I am delving into the world of Vue.js. In my journey, I have crafted a plugin that takes the form of: source/myPlugin.js const MyPlugin = { install: function(Vue, options) { console.log('installing my plugin'); Vue.myMetho ...

retrieve information at varying intervals through ajax

In my web page, there are two div elements that both fetch server data using AJAX. However, div-a retrieves data every second while div-b retrieves data every minute. How can I adjust the frequency at which each div fetches server data? ...

Error in initializing UI-router wrapper due to circular dependency in Angular.js

I've been following the angular style guide of John Papa (https://github.com/johnpapa/angular-styleguide#routing) and implementing a custom wrapper for angular ui-router as suggested. However, I'm encountering an issue with the wrapper causing a ...

Troubleshooting Proxy.php issues in conjunction with AJAX Solr

Attempting to access a Solr 4.5.0 instance located on a private server, http://12.34.56.789:8983/ The application resides at this web server address, http://www.mywebapp.com To facilitate accessing the JSON object within the Solr instance, I decided to ...

Animating with React JS using JSON data sources

Currently, my project involves using React/Redux to store animation data in JSON and display it on a React page. The challenge lies in implementing the animations correctly while utilizing setTimeout for pauses and setInterval for movement. The Animation ...

JQuery Multi-Filterizer

My webpage showcases a list of posts from custom-post-type. For each post, I am displaying the title, status, and category: <div class="adherents"> <article class="adh-1185 association work adh"> <h2>Title</h2> ...

Differences between variable scope in Node.js and web browsers when running JavaScript code

When it comes to browser, different JavaScript files share one scope: a.js: var a=1; //by adding "var", we prevent it from becoming a global variable. b.js: console.log(a) //even though a=1, b.js can still access this variable! In Node.js: a.js .... b ...

What is the best way to horizontally align an element within a Material UI Grid item?

How do I align elements in the center of a Material UI Grid item? Check out this code snippet from my React project: <Grid container> <Grid item xs={4}> // Other content goes here </Grid> <Grid item xs={4}> // How can ...

Building a website using Bootstrap: A step-by-step guide

Wondering how I can incorporate all the cool Bootstrap components into a webpage. Is there a tool that offers live preview? Back in the day (web 1.0), Dreamweaver was my go-to for creating HTML and basic CSS, but what are some current tools where I can si ...

Determine the total quantity of colored cells within a row of an HTML table and display the count in its own

I need assistance with a table that has 32 columns. From columns 1 to 31, I am able to fill in colors by clicking on the cells. However, I now want to calculate and display the number of cells that are not colored in the last column. This task must be co ...

Combining multiple images into one CSS image sprite to create 4 clickable

Could someone please review this segment of the CSS to ensure its accuracy? CSS #nav-list { list-style-type: none; background-repeat: no-repeat; background-image:url("../_img/Footersprite.png") } #nav-list li, #nav-footer a { height: 40 ...

Selecting nested <div> elements in jQuery can be

What is the best way to target a div element that contains the text "my content"? <table> <tr> <td class="ms-disc-bordered-noleft"> <div class=""> <div>some content</div> <div>my conten ...

The absence of a Bootstrap modal triggering upon page load is causing an issue

After implementing a login/signup modal on my website, I discovered that it works well, but I want it to open automatically when the page loads. I found the initial code for the modal here. I made changes to the code to try and open the reset password mod ...