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 8338663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:39:53+00:00 2026-06-09T04:39:53+00:00

Maybe this is a browser related issue? I’m on Chrome at the moment… What

  • 0

Maybe this is a browser related issue? I’m on Chrome at the moment…

What I’m trying to accomplish is allow the user to save text that they’ve selected (highlighted) on the page with their cursor.

I’ve got the javascript/jQuery/ajax all setup…and it works like a charm when I’m testing it via the console.

i.e. – I select some text and then run this command.

alert(getSelected());

To which I get an alert popup with the selected characters.
…so it works in theory.

HOWEVER – When I want to use a button to make the call, what’s happening is that the text selection dissapears FIRST, and thus I am unable to then see/save what they’ve selected.

<script>
$('#save').click(function(){
  var selected_text = getSelected();
});
</script>

<div id="save"><img src="the_save_button.jpg" height="50" width="50" /></div>

Is there a way to maintain the text selection upon clicking/after clicking the “save” DIV?

Open to any and all solutions!! Thanks!

  • 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-09T04:39:55+00:00Added an answer on June 9, 2026 at 4:39 am

    One easy option is to use mousedown instead of click. However, this is different to the native behaviour of buttons, which is to fire an action when the mouse button is released, so is not great UI.

    Another option is to make the clickable element unselectable, using a combination of proprietary CSS properties and the unselectable attribute for IE and Opera, which prevents the click from clearing the selection:

    Demo: http://jsfiddle.net/timdown/UUQJs/

    CSS:

    .unselectable {
        -khtml-user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    

    HTML:

    <div id="save" unselectable="on" class="unselectable"><img
       src="the_save_button.jpg" height="50" width="50" unselectable="on" /></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is a poor question, but, I can't find a tutorial or even
Maybe this isn't possible due to Security implications... I have a Deployment Package created
Maybe this is something very easy to do it but so far it's taking
Maybe this is a dumb question, but do event listeners use CPU cycles like
Maybe this sounds a little bit crazy, but I need to come up with
Maybe this isn't really feasible. But basically, I've been developing a snippet-sharing website and
Maybe this question has been asked many times before, but I never found a
Maybe this is stupid, but are there any drawing elements in Xcode 4.2 ?
Maybe this has been answered before, but I was not able to find it.
Maybe this is a silly question, but I'm working on a project that wants

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.