You are unable to select the element in IE if there is an image in the background

Apologies for coming back with the same question, as I realize now that I was not clear in my explanation yesterday. You can find the codepen here (please note that it may not open in IE8). My issue is with dragging the 'move-obj' element in IE browsers 8, 9, and 10 when there is an image in the background. How can I modify this demo to work correctly on IE browsers above version 8?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<title>Document</title>
<style>
    .wrap{
        position: relative;
        width: 100%;
        height: 100%;
        background-color: #f0f0f0;
        padding: 10%;
    }
    .wrap-inside{
        position: absolute;
        top: 100px;
        left: 100px;
        width: 502px;
        height: 502px;
        border: 1px solid #ddd;
    }
    .move-obj{
        cursor: move;
        position: absolute;
        top: 100px;
        left: 100px;
        width: 100px;
        height: 100px;
        border: 1px solid blue;
        background-color: rgba(0, 0, 0, 0); // adding a background here allows it to work in IE9 and IE10
       filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#00000000,endcolorstr=#00000000); // does not work in IE8

    }
    .bg{
        top: 102px;
        left: 102px;
        width: 500px;
        height: 500px;
        position: absolute;
    }
</style>
</head>
<body>
<div class="wrap">
    <img class="bg" src="images/img1.jpg" alt=""> // removing this tag makes it work correctly
    <div class="wrap-inside">
        <div class="move-obj"></div>
    </div>
</div>
<script src="js/jquery.min.js"></script>
<script>
    $('.move-obj').on('mousedown', function(e) {
      var start_x = e.pageX;
      var start_y = e.pageY;
      var $that = $(this);
      var t_left = parseInt($that.css('left'));
      var t_top = parseInt($that.css('top'));
      $('.wrap-inside').on('mousemove', function(e) {
        $that.css({
          left: t_left + e.pageX - start_x,
          top: t_top + e.pageY - start_y
        });
      }).on('mouseup', function(e) {
        $(this).off('mousemove');
      });
    });
</script>
</body>
</html>

Answer №1

To achieve a transparent background for the .move-obj element, you can use a transparent image or set it as url(about:blank) which should also be effective.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The fade in and fade out effects using JQuery are not functioning as expected despite adding a delay

I am attempting to achieve a text effect where the text fades in, stays visible for a moment, and then fades out. While I understand this can be done with CSS Keyframes, I am unsure of how to implement it with multiple animations. As a result, I am experi ...

Conflict with iScroll

When using an HTML5 template in Mobile Safari on iPad, I encountered an issue with a div containing iScroll. Within this div, there is a jQuery function within an if/else statement which tests if the user is tapping outside of the iScroll div and fades it ...

Is it possible for webkit CSS resize to not function properly when applied to a canvas element that is

Consider this HTML and CSS code snippet: #box { width: 100px; height: 100px; overflow: hidden; resize: both; border: 1px solid black; } #content { width: 100%; height: 100%; } <div id="box"> <canvas id="content"> ...

I need to obtain the URL pathname on a server component in Next.js version 13 - how is this achieved

I'm facing an issue with retrieving the pathname of a server component located in the app directory. Despite attempting to obtain it through window.location, I haven't been successful. Is there an alternative method I can use to achieve this? ...

Rerender not occurring after array splice with React hooks setter

My parent component structure is as follows: import React from "react"; import Test from "./Test"; function App() { const [configs, setConfigs] = React.useState([1, 2, 3]) return ( <div> ...

Guide to making a Material Design Radial effect animation

I am looking to create a unique toolbar effect by following the material design radial reaction choreography guideline. https://i.stack.imgur.com/6oB8r.gif I want to achieve this using an angular 2 transition, but I need some guidance on how to implement ...

HTML: Dealing with issues in resizing and resolution with floating elements on the left and right using

Encountering some issues with the HTML code below when resizing the window: 1: The right bar suddenly drops down if the width is made too small. 2: The spacing between the content and the right bar expands as the window width increases. <style ty ...

Whenever I attempt to execute my .html and .js files, I encounter the error message: "Uncaught SyntaxError: Unexpected token <"

Just starting out in react.js, I decided to include CDN links to compile some basic react.js code into my html. Unfortunately, I encountered this error: "Uncaught SyntaxError: Unexpected token <" I did some research and found a suggestion to add: t ...

Ways to divide the header column of a bootstrap 4 table?

Currently, I am delving into the realm of frontend development and facing a challenge with designing a table. My goal is to merge multiple columns into a single column by dividing them into cells. I am aware of the bootstrap classes colspan and rowspan, ho ...

Display a clock showing the Central Standard Time (CST) on an HTML webpage using

Is there a way to display the current time in CST time format on an HTML page using JavaScript? I need it to be shown in the following format: "02 Jul 2015 10:34:45 PM" ...

Transform a flat 2D shape into a dynamic 3D projection using d3.js, then customize the height based on the specific value from ANG

Currently, I am utilizing d3.js version 6 to generate a 3D representation of the 2D chart shown below. Within this circle are numerous squares, each colored based on its assigned value. The intensity of the color increases with higher values. My goal is t ...

Prevent Duplicate Submissions with jQuery Ajax form disabling

Enhancing Ajax form submission. I am looking to disable the form from being submitted again until the previous submission is completed. Would it be sufficient to just disable the input or text area, or should I also disable the submit button? ...

Counter is effective for the initial post, yet it does not function properly for the subsequent post

Can anyone help with an issue I'm having with my JavaScript counter? It works for the first comment, but not the second one. This problem persists whether I use PHP or JavaScript. Below is the JavaScript code for the counter: var count = (function() ...

What method does the CSS standard dictate for measuring the width of an element?

In terms of measuring an element's width, Chrome appears to calculate it from the inner margin inclusive of padding. On the other hand, Firefox and IE determine the width of the box from the border, excluding padding but including the margin. Personal ...

Styles brought in from external sources do not get applied to components

My goal is to create a separate file specifically for storing styles targeted at IE 9-11. In order to achieve this, I have created a file named InternetExplorer.scss and imported it into my main file styles.scss: @import "scss/InternetExplorer.scss"; The ...

Error: The operation 'join' cannot be performed on an undefined value within Fast2sms

I am encountering issues while attempting to send SMS using fast2sms in Node.js. The error message reads as follows: TypeError: Cannot read property 'join' of undefined at Object.sendMessage (C:\Users\user\Desktop\node_module ...

If the variable is not defined, then utilize a different one

There are two scopes: $scope.job and $scope.jobs. I also have a variable called job; If $scope.job is undefined, I want $scope.jobs to be assigned to the job variable using the following code: var job = $scope.jobs. However, if $scope.job is defined, the ...

Delicate seams break up the different sections of the webpage

I'm facing an issue with my website where thin lines are appearing between each section when previewed in Safari and Chrome, but not in Firefox (as shown in the images). I've checked the CSS code for each section in Dreamweaver, where the lines d ...

Why does the entire page in Next.JS get updated whenever I switch pages?

Currently, I am utilizing Next.JS to create a single-page application website in React. I have successfully set up routing (https://nextjs.org/docs/routing/dynamic-routes) In addition, I have also configured Layouts (https://nextjs.org/docs/basic-features ...

The performance of Three.js is directly influenced by the quantity of objects present

Just completed a project in WebGL using Javascript and the 3D library known as three.js Unfortunately, the performance of the project is less than impressive - slow from the start with occasional moments of adequacy. In this game, there are: 1 car, 6 ora ...