Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:14:26+00:00 2026-06-03T04:14:26+00:00

I am using a html editor to edit content. Now i need to make

  • 0

I am using a html editor to edit content. Now i need to make sure a very special kind of element does not get deleted (images with a special class).

For the use cases of a non-collapsed selection/range with BACKSPACE, DELETE, CTRL + X/CMD + X i found a solution, but i am still looking for a solution to the case that the selection/range is not collapsed and the next Backspace will delete one of my special images.

How can i detect if the next Backspace/Delete will remove one of those img-tags ?

Example: CARET marks the caret/cursor position. If Backspace will be pushed next the image will get removed. How can i detect this case?

<p>Some Text <b>here <img class="my class" src="..."/></b>CARET some text</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:14:27+00:00Added an answer on June 3, 2026 at 4:14 am

    The code below detects elements around caret with onkeyup (and onselectionchange), but it’s for IE only. Maybe it can be “translated” to jQuery.

    function detectClass(){
        var range, parentR, parentL;
        range = document.selection.createRange();
        range.moveStart('character',1);
        range.moveEnd('character',1);
        parentR = range.parentElement();
        range.moveStart('character',-2);
        range.moveEnd('character',-2);
        parentL = range.parentElement();
        if (parentR.className == 'special'){/* special on right */}
        if (parentL.className == 'special'){/* special on left */}
        return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

fck editor does not show my html tags, when i view the source using
I'm currently using TinyMCE as html editor for users of my CMS. Somehow the
I have Drupal 6 website which is using FCK Editor as HTML editor. It
I'm using MVC 2, and the Html.EditorForModel() to allow me to display an editor
I'm using Javascript inside of a SharePoint 2010 Content Editor Web Part to insert
I need to create a text editing control in C# and I'm not sure
Background:- Am using a JS editor on my site. Now when I copy paste
Using HTML and CSS. I have text surrounded by a border using display:inline to
Using html and css for IE7, how do I position a html table at
Using HTML 5 together with the DOM is there a way to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.