Place the dynamic textarea directly on top of the current box element

Looking for a solution to place a textarea element directly over an ordered list (<ol>) with list items (<li>). This would allow the user to edit the list.

The translation functions to convert items to text and vice versa have already been implemented. For the second part, all the <li> elements are removed and recreated from the text.

The challenge lies in positioning this textarea precisely over the list.

Edit:

Below is some code snippet:

<h2>TODO List</h2>
<div id="container">
    <ol id="theol" style="margin-left: 10px; padding-left: 15px; width: 270px; border: 1px solid Gray;">
        <li><span>Locate the ol element</span></li>
        <li><span>Add the text input after it</span></li>
        <li><span>Change text input style to position it over the &lt;ol&gt;</span></li>
        <li><span>Capture ENTER or ESC (maybe blur() too)</span></li>
        <li><span>If ESC then just abandon everything</span></li>
        <li><span>If ENTER (or blur()) then clear all the &lt;li&gt; and recreate them</span></li>
        <li><span>Get rid of input</span></li>
    </ol>
</div>

<script src="http://cdn.jsdelivr.net/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

<!-- injected script -->
<script type="text/javascript">
    var theol = $('ol#theol');
    var newlist = $('<textarea/>').insertAfter(theol);
    // how can we position 'newlist' exactly over 'theol'?
</script>

Note that the script is injected through a bookmarklet, so pre-existing data cannot be controlled. Additionally, the styling may not be fixed as shown above (such as margin, padding, width), and the height might vary based on content.

Answer №1

try using a container element such as:

<div class="container">
   <ul>
   </ul>
   <textarea></textarea>
</div>

ensure proper positioning and z-index values like so:

.container{
   position:relative;
   z-index:1;
}

.container textarea{
   position:absolute;
   z-index:1;
   top:0;
   left:0;
}

be sure to adjust the width and height accordingly

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

Mapping tasks in React won't be successful with the map function

Currently delving into React and building a to-do section of a MERN app. I transformed the task object from MongoDB into an array and am attempting to display the tasks on the screen using the map function. The get request is successful as the array shows ...

Update the query string to accommodate several values

Having an issue with my query string. Whenever multiple values are selected, my Django search function malfunctions. The URL displays ?Query=value1&Query=Value2, but only the last value is actually searched. I need both values to be searched using an A ...

What is the process for utilizing the item.split function with two parameters?

When working with an array and using the forEach method, each item in the array is formatted as "text;text" or "text:text". After splitting these items, a question arises on how to programmatically differentiate between the two separators. array.forEach ...

Optimizing Google e2e testing using Protractor

Improving login efficiency is necessary to enhance the speed of executing e2e tests. At present, after every test, the Chrome browser shuts down, requiring a new login session for each subsequent test. What changes can be made to address this issue? Any ...

Determine the area and perimeter of a triangle using the lengths of the sides provided

I am currently working on a program that is designed to compute the area and circumference of a triangle based on user input for the lengths of its sides. Unfortunately, I have encountered some issues with my code that I am struggling to comprehend fully ...

Choose autocomplete feature from an external source within the context of AngularJS

I am currently working on an autocomplete textbox and I stumbled upon this script that I found through my search efforts. .controller('autoCompleteCTRL', function($scope, $rootScope){ $rootScope.searchItems = [ "ActionScript", ...

Limit the maximum value for a NUMBER input in vue - a step-by-step guide!

Currently, I am attempting to develop a new input function that will reject any number entered by the user if it exceeds a specified limit. However, I have encountered some issues with this. Let's assume the maximum allowed number is 99. Currently, m ...

When I try to make an on-demand revalidation API call on Vercel, it takes so long that it ends up timing

Inspired by Kent C. Dodds, I have created a blog using Github as my Content Management System (CMS). All of my blog content is stored in the same repository as the code, in mdx format. To streamline the process, I set up a workflow that detects changes i ...

How do I apply a xPage page style using the styleClass attribute instead of directly using the style attribute

Would like to know how to change the background color of an entire page using styleClass instead of directly in the xp:view tag? Here's an example that works: <xp:view xmlns:xp="http://www.ibm.com/xsp/core" style="background-color:#f1f1f1;"> ...

Exploring the variance in outcomes when directly accessing an AuthService state versus utilizing a function in a React AuthContext

I am currently working on creating an AuthContext, but I am encountering an issue with changing the state of a variable. Here is the code snippet: index.js import Head from "next/head"; import Image from "next/image"; import styles fro ...

Text wrapping over in 5 column design using Bootstrap

After building a simple webpage with Bootstrap 5, I've run into an issue where the text in the columns overlaps. When the screen is at its full size, everything looks good. But as I start to reduce the size of the screen, the text gets smaller until t ...

Use anchor tags on the client side instead of server side @Url.Action

I have developed an asp.net mvc 5 application that displays a user's emails. When the user clicks on an email, another action is triggered to show the content of that specific mail. Recently, I wanted to add pagination for the inbox and ended up imple ...

What is the best way to conceal or eliminate slider increments and their corresponding labels in plotly.js?

Is there a way to eliminate or conceal the step ticks and labels of the animation slider? I want to get rid of the slider's step markers (ticks) and the corresponding labels: 'Red', 'Green' and 'Blue' located beneath the ...

Retrieve the data attribute from the last three tag names using the Jquery Prev() method

Hi there! I'm currently trying to map out the route for going from clicking a button on the ADDtab_138269500 and then navigating back (to the previous) all the way to the first encountered span tag but in reverse order. If you want to view the code, ...

Move progress bars in an upward direction

Having trouble animating progress bars with jQuery? I am facing a unique issue where my progress bars are behaving in an unexpected way when using the jQuery animate() method. My goal is to animate each progress bar individually with a 0.1s delay. I need g ...

Angular's ng-repeat allows you to iterate over a collection and

I have 4 different product categories that I want to display in 3 separate sections using AngularJS. Is there a way to repeat ng-repeat based on the product category? Take a look at my plnkr: http://plnkr.co/edit/XdB2tv03RvYLrUsXFRbw?p=preview var produc ...

Bizarre discrepancies in text wrapping across various browsers

After encountering a larger issue, I found that I could reduce it to a simpler scenario: To see the problem in action, check out this jsFiddle link: http://jsfiddle.net/uUGp6/ Here is the simplified HTML code: <div class="box"> <img class=" ...

Ways to include a js configuration file within a TypeScript npm package that can be customized by future users of the package

In my current project, I am working on coding a Typescript NPM package designed to function as a CLI tool. To simplify things, let's imagine that this package will take the default export from a developer-created "config.js" file and display it in th ...

AngularJS not updating numbers

Starting out with Angular, my first project involves creating a system that highlights and iterates over rows and then, when clicked, iterates over columns. However, I'm encountering an issue where the numbers are not changing in my $interval function ...

Why am I encountering this export issue while attempting to integrate a NextAuth.js Provider with Next.js?

Embarking on my first project in React/Next.js, I opted to employ NextAuth.js for authentication. Following the initial steps outlined in the Getting Started guide provided by NextAuth, I have successfully set up a [...nextauth].js page featuring the code ...