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

  • SEARCH
  • Home
  • 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 6626617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:54:47+00:00 2026-05-25T21:54:47+00:00

I have these two functions: var $mainEdit= $(#main-edit); function getSelText() { var txt =

  • 0

I have these two functions:

var $mainEdit= $("#main-edit");

    function getSelText()
    {
        var txt = '';
         if (window.getSelection)
        {
            txt = window.getSelection();
                 }
        else if (document.getSelection)
        {
            txt = document.getSelection();
                }
        else if (document.selection)
        {
            txt = document.selection.createRange().text;
                }
        else return;
    return $("#clipboard").val(txt);
    }
    $mainEdit.mouseup(function(){
        $("#clipboard").val("");
          getSelText();  
        }).mousedown(function(){
        $("#clipboard").val("");
          getSelText();
        });

What I want to do, is on the keyup event…the highlighted elements would be removed.

So if I had this html:

<span>a</span>
<span>b</span>
<span>c</span>

and highlighted a and b, on the keyup event, the first two spans would be removed.

  • 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-05-25T21:54:48+00:00Added an answer on May 25, 2026 at 9:54 pm

    Here’s a cross-browser function for deleting selected content:

    function deleteSelected() {
        if (window.getSelection()) {
            window.getSelection().deleteFromDocument();
        } else if (document.selection) {
            document.selection.clear();
        }
    }
    

    Hooking it up to the keyup event:

    $mainEdit.keyup(deleteSelected);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two functions function ShowCrossWord(var randN) { randomnumber = randN; $(document).ready(function() { $.get(crosswords.xml,{},function(xml){
I have these two functions: jQuery.fn.enterText = function(e){ if( $(#cursor).val() && e.keyCode != 32
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
For example, compare these two: function Person(name) { this.name = name; } var john
So i have these two jquery functions which pass my XHR service a key
So I have these two functions, public static string[] CharToHex(string str, string prefix, string
I have the following two functions and i need help moving these into an
If I have two byte[] arrays, is there a built-in function to compare them
I have these two pieces of code, wich one is more readable? foreach decimal
I have these two modules : package G1; sub new { my $class =

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.