The issue of the cursor not showing up in Chrome within a nested contenteditable structure arises when applying CSS after the

Currently, I am coding a HTML document that includes an element with the attribute contenteditable set to true, but this element is wrapped inside a parent element with contenteditable set to false. The HTML structure looks like this:

<div contenteditable=false>
    <div contenteditable=true>
        <p>Abc</p>
        <p>Def</p>
    </div>
</div>

If you want to see it in action, here is the JSFiddle Link: http://jsfiddle.net/mpsingh2003/gxbqujdw/1/

To replicate the issue, follow these steps: Open the link in Chrome

  1. Click after the "@" symbol in the line containing the text 'Def'
  2. Now click after the "@" symbol in the line containing the text 'Abc'. The cursor does not appear.
  3. If you click to the left of the "@" symbol in the text 'Abc', the cursor will appear. Then, clicking to the right of the "@" symbol will move the cursor to the desired position on the left of the "@" symbol.

In Firefox and Edge browsers, this functionality works as expected, with the cursor always appearing on the left when clicking to the right of the "@" symbol in any line. If anyone has any suggestions for an HTML or CSS solution, or if Javascript or jQuery needs to be used, please feel free to share.

Answer №1

To resolve this problem, it is recommended to update the CSS.

One possible solution is to utilize the Display property in p:after.

Feel free to take a look at this demonstration for reference.

Answer №2

Resolved the problem by setting :after to position:absolute (tested in Chrome):

p:after {
content:"@";
position:absolute;
cursor:text;
z-index: -1;
}

Check out the solution on fiddle

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

Step-by-step guide on crafting a scrolling marquee with CSS or Javascript

I am in need of creating two marquees for a website project. The first marquee should showcase a repeating image while the second one should display links, both spanning the browser window at any size. It is crucial that the marquee items are displayed fro ...

issue with data binding in ons-dialog

Utilizing an ons-dialog to display a popup prompting the user to sign up for a newsletter. I have set a 3-second timeout to prevent users from immediately closing the prompt without reading it or waiting. I aim to initially show the dialog with the ' ...

Having difficulty retrieving text from textarea with jquery

I'm experiencing an issue with my jquery script where the top two buttons are showing 'undefined' instead of performing the same action as the buttons below them. Could someone please pinpoint where I went wrong? I want the two buttons at t ...

Why does the socket.io output only appear after I refresh the page?

Feeling stuck and seeking guidance. After following tutorials, I was able to develop a basic user registration/login app in nodejs/express with the addition of a socket.io chat feature. Upon user login, they are directed to the real-time chat page where i ...

javascript for each and every textarea

I am looking to apply my JavaScript code to all the Textarea elements on my page. $_PAGE->addJSOnLoad(" $('.textarea').each(function() { $(this).keyup(function() { var characterCount = $(this).val().length; var mes ...

Implementing Autocomplete search with jQuery Chosen plugin - a step-by-step guide

CSS <select class="custom" id="company_hub" name="company_hub" style="width: 400px; display: none;"> <option>-Select Item-</option> </select> https://i.sstatic.net/x4YtN.png I attempted the following method but it was unsucces ...

Scroll to the top of a new page with Material UI's table component

Feeling a little stuck here. I've tested various settings with scrollTop, but haven't had much luck. To clarify, I'm working with Material UI and their pagination features in conjunction with a table (you can find the documentation here). W ...

Struggling with implementing click events on Ionic-Calendar 2?

Attempting to implement a (click) event for ionic-calendar 2 where it deactivates a button if the user clicks on a date that has already passed. The issue I am facing is that when I initially click on a past date, the button remains enabled. However, upon ...

What is the best way to remove multiple IDs from req.params using Sequelize?

Is there a way to handle req.params that contain multiple IDs? I need to search for and delete these multiple IDs. Here is the code snippet: const ids = req.params; const masterFunders = await masterFunder.findOne({ where: { id: ids ...

Searching for results using the .find() method may yield elements that do not meet the specified search criteria

Utilizing the .find() method on my JSON object called records: [ { "_id": "61f9da9fcc6888f201f722cb", "firstName": "joe", "lastName": "jergen", "email": "<a hre ...

Tips for formatting dates in Angular 6

I am currently working on a function that displays real-time dates based on user input. Currently, when the user enters the input, it is displayed in the front end as follows: 28.10.2018 10:09 However, I would like the date to change dynamically based on ...

Can you elaborate on the contrast between React Server Components (RSC) and Server Side Rendering (SSR)?

I'm curious about the differences between RSC in React 18 and SSR in NextJS. Can anyone explain? ...

Implementing an active state for the 'a' tag within Bootstrap 5 nav-tabs in an MVC application can be achieved by utilizing ActionLink

In my .NET MVC application, I am utilizing Bootstrap 5.1 to create navigation tabs with 'a' tags generated via ActionLink. <ul class="nav nav-tabs"> <li class="nav-item"> @Html.ActionLink("Enti ...

Display a pop-up window upon clicking anywhere on the webpage using jQuery and HTML

Is it possible for me to create a pop-up window that opens a specific website when a user clicks anywhere on the page, similar to pop-up companies? Can this be achieved using HTML, JavaScript, and jQuery? Any help would be greatly appreciated. ...

I'm struggling to update a value in my view with Angularjs and Socket.io. It seems impossible to

In order to master AngularJS and NodeJS, I am embarking on creating a chatroom project. Everything seems to be functioning smoothly with Angular controllers and sending data to my NodeJS server using socket.io. However, I have encountered a problem: When m ...

User should clear the cache to accommodate the latest release

After each release, users are required to manually clear their cache in order for the new code to be applied. Is there a feature or method that could automate this process? ...

Compare the current return value to the previous value in the success callback of an Ajax request

I am currently running an Ajax request to a PHP DB script every 3 seconds, and I need to make a decision based on the result returned. The result is a timestamp. Let's say the ajax request is fired two times. I want to compare the first result with th ...

The functionality of using multiple inputs with Google Places API is not functioning as expected

Having trouble with the Google Place API. I am unable to set up 2 input fields with autocomplete. The first input is populated from a payload received from the backend, while the second input is within a Bootstrap modal. I have tried various solutions fou ...

The MVC framework coupled with a robust Javascript/JQuery validation library is a winning

Currently, I am involved in a project that utilizes MVC 2.0 along with Kendo UI. Our team has made the decision to utilize AJAX validation instead of MVC Model level validation. This means that validation occurs during most "onchange" events on HTML contro ...

Displaying leap years and non-leap years in distinct tables

I attempted to organize the display of leap years and non-leap years from 1991 to 2100 into two separate tables, but unfortunately, I was unsuccessful. Could you kindly offer guidance on how to present this information in a table format or a grid system? ...