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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:13:11+00:00 2026-06-10T15:13:11+00:00

I have a link, and if you drag this link then release, the link

  • 0

I have a link, and if you drag this link then release, the link will keep his active state.

Example: http://jsfiddle.net/Ek43k/3/

<a href="javascript:void(0);" id="foo" >Drag me</a>

#foo:active{
    color:red;
}

How can I prevent this?

(Only in IE and FF)

  • 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-10T15:13:13+00:00Added an answer on June 10, 2026 at 3:13 pm

    Detach and reattach the link from the DOM tree to disable its active state. Do this when the drag ends and you’ve got this:

    $('a').on('dragend',function(){
        var $this   = $(this),
            $parent = $this.parent(),
            $next   = $(this.nextSibling); // $.next() doesn't include text
        $this.detach().insertBefore($next);     
    });
    

    No need to mess with your HTML or CSS or do away with :active. Seems to work in both FF and IE.


    Edit: I don’t usually write pure Javascript for DOM-handling so the quality of this might not be top notch, but here it is without jQuery:

    (function(){
        var previousOnload = window.onload || function noop(){};
    
        window.onload = function (){
    
            // Call any previously added onload callbacks
            previousOnload();
    
            // Add deactivator to each <a> element
            var elements = document.getElementsByTagName('a');
            for (var i=0; i<elements.length; i++){
                elements[i].ondragend = deactivate;
            }
    
            function deactivate(){
                var parent   = this.parentNode,
                    position = this.nextSibling;
                parent.removeChild(this);
                // Using insertBefore instead of appendChild so that it is put at the right position among the siblings
                parent.insertBefore(this, position);
            }
        };
    
    })();
    

    I took care of a few issues that came to mind to make it fully plug-and-play. Tested in Opera, Chrome, Firefox and Internet Explorer.


    Edit 2: Inspired by Chris, another way to apply the fix is to use the ondragend attribute directly to connect the deactivator (not tested):

    <head>
        <script>
            function deactivate(){
                var parent   = this.parentNode,
                    position = this.nextSibling;
                parent.removeChild(this);
                // Using insertBefore instead of appendChild so that it is put at the right position among the siblings
                parent.insertBefore(this, position);
            }
        </script>
    </head>
    <body>
        <a href="#" ondragend="deactivate()">Drag me</a>
    <body>
    

    The downside is that it requires the ondragend attribute with javascript to be specified on each link manually/explicitly. I guess it’s a matter of preference.


    Final (?) Edit: See comments for delegate/live versions of these and Chris’ answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is better explained in: http://jsfiddle.net/tRBaV/1/ I have two kinds of entities: containers and
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have looked at the this link for a tutorial on dojo drag and
I have a small script where you can drag the link, but I also
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have this link in a template: <a href={% url show_item item.id %}>Item 1</a>
I have a link, with which i want use plus, which will change color
I have a link as bellow. Is there any way to change info@example.co.uk with
EDIT: Here's a link to show you my sample code: http://www.singingeels.com/jqtest/ I have a
i want to populate this json http://www.godsgypsychristianchurch.net/music.json using a get request, there are multiple

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.