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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:20:28+00:00 2026-05-28T08:20:28+00:00

I have an image which when onmousedown is triggered, it runs a function that

  • 0

I have an image which when onmousedown is triggered, it runs a function that changes its class and makes it draggable, however the first time I drag it it wont drag, it changes the class but will not drag? After the intial failed drag, if you then drag again it will drag but why wont it drag at first?

function element_click(element_class) {
  $("#" + element_class).draggable("enable");
  $("." + element_class).addClass("element_select");
  $("#" + element_class).draggable({
    disabled: false,
    opacity: 0.9,
    revert: true,
    stop: function(event, ui) {
      $(".element_select").removeClass('element_select');
      $("#" + element_class).addClass(element_class);
      $("#" + element_class).draggable("disable");
    }
  });
}


<img id="element_air_1" style="z-index: 5;" class="element_air_1" 
 onmousedown="javascript: element_click('element_air_1')" 
src="Doodle God Elements/air.png">
  • 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-28T08:20:29+00:00Added an answer on May 28, 2026 at 8:20 am

    Add this block of code to your script:

    window.onload = function(){
        element_click($('#element_air_1').attr('class'));   
    }
    

    It will trigger your script before your first click.

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

Sidebar

Related Questions

I have and image which gets stretched to its full background, regardless of the
I have an image which is rotating and what I want is that a
I have a question that I have an image which is shown on an
I have an image which is has an onmousedown event . When I hover
I have an image which is representative of an Array2D: template<class T = uint8_t>
I have a view and template called index.html. I have a image which is
Hope someone has an easy answer on this. I have a header image which
I have an object of type IMAGE which holds image. I wanted to display
I have a small (100x80) overlay image which will be placed at x=40, y=50
How to do the following: I want to have a link [upload image] which

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.