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 Vue component should trigger the display of data in a Bootstrap modal based on the row of the button that was

Here is a sample code snippet demonstrating how data is fetched from the database: <table class="table table-bordered"> <thead> <tr><th>User ID</th><th>Account Number</th><th>Accou ...

What is the best way to open a link contained within a div by clicking on it

I am currently in the process of developing a website that is able to parse a Spanish dictionary. When looking up the word HOLA, the site provides the definition. However, for other words like CASA, users receive suggestions with links such as My goal is ...

Using Angular to make a DELETE request using HttpClient with a Json Server

My goal is to remove one employee at a time from the Employees list. The Observable is configured in employee.service.ts and subscribed in app.component.ts. However, there seems to be an issue connecting the id of the employee with the removeUser(id) metho ...

V-Calendar is not displaying the accurate dates

https://i.stack.imgur.com/zk4h7.png The image displays dates starting on June 1, 2022, which should be a Wednesday but appears as a Sunday on the calendar. This issue affects all months as they start on a Sunday instead of their respective weekdays. The p ...

Utilize ModifyDOM to erase text triggered by selecting a radio button

I have created a form that includes four radio buttons along with a reset button to clear the form. When a radio button is selected, information is displayed using "displayText". I am looking to add an onclick handler to trigger a function that will delete ...

Elegant Modal Form Submission Using jQuery

Having trouble submitting a modal jQuery form? A code snippet was borrowed from a website with minor modifications and the JavaScript was moved to a separate file. The challenge lies in transmitting form data to a PHP script via AJAX. The serializedArray() ...

Adjust: Return scale to default

By applying transform: rotate(-2deg); to a section, I have created an effect where the section rotates slightly. Additionally, when the user hovers over the same section, it increases in size due to transform: scale(1.1);. However, on one specific page of ...

Is there a way for me to retrieve the variable from one function and use it in another

I have a tool for managing images with descriptions that allows me to edit both the text and the image file. The challenge is saving the modifications I make in my database. Currently, I can only save changes if I modify the image itself. If I only update ...

How can I effectively combine jquery validate with $.ajax for validation and form submissions?

How can I effectively use jquery validate and $.ajax in conjunction? My goal is to save form data using Ajax after it has been successfully validated: jQuery(document).ready(function() { $('#np-submit').click(function() { if($("#new ...

Change the order of the table data elements using the nth-child CSS selector

I need the second td in my table to appear on top of the first one when I resize the screen. @media screen and (min-width: 200px) and (max-width: 872px) { td :nth-child(1) {display:bottom} td :nth-child(2) {display:top} } <table border="0" cell ...

The state in Reactjs is not displaying as expected

Check out my ReactJS todo app that I created. However, I am facing an issue with deleting todos. Currently, it always deletes the last todo item instead of the one I click on. For example, when trying to remove 'Buy socks', it actually deletes ...

Convert a tuple into a JSON string

Looking to serialize a tuple into JSON: List<Tuple<string, string, string, string, string, string>> iCalEvents = new List<Tuple<string, string, string, string, string, string>>(); When I use the following code to output the value: ...

Creating an HTML table that automatically generates sub rows dynamically

Looking to provide users with the ability to construct a table where they can create expressions. For example, in the expression shown below (((c1 A/O c2) A/O C3) A/O C4), where A/O represents 'And' and 'Or' conditions selected by the u ...

Learning the ins and outs of HTML5 and CSS3

Does anyone have recommendations for high-quality HTML5 and CSS3 tutorials? ...

The viewport scaling issue occurs when transitioning from landscape to portrait orientation

While developing a mobile version of my website, I have encountered an issue with the behavior when rotating my iPhone device. Everything looks fine in landscape orientation, but upon rotation back to portrait, the viewport remains stuck at the landscape s ...

A gojs swim lane diagram requires a date axis to provide accurate time representation

I am currently working on a web application that requires a vertical swim lane activity diagram with a customized date axis displayed alongside it. The nodes in the diagram should be positioned based on their date attribute, and users should have the abili ...

What is the method for activating a button when a user inputs the correct email address or a 10-digit mobile number

How can I enable a button when the user enters a correct email or a 10-digit mobile number? Here is my code: https://stackblitz.com/edit/angular-p5knn6?file=src%2Findex.html <div class="login_div"> <form action=""> <input type="text" ...

The React JSX error you encountered is due to the missing return value at the end of the arrow function

After implementing my code, I noticed the following: books.map(({ subjects, formats, title, authors, bookshelves }, index) => { subjects = subjects.join().toLowerCase(); author = authors.map(({ name }) => name).join() ...

Tips for Showing Certain Slides When the Page Loads

When using jQuery filter effects to organize div slides on a page, I encountered an issue where all the divs containing different slides are displayed on page load instead of just the default chosen ['active'] div. The filter effect itself is fun ...

Wait until a svelte store value is set to true before fetching data (TypeScript)

I have implemented a pop-up prompt that requests the user's year group. Since I have databases for each year group, I need to trigger a function once the value of userInfo changes to true. My JavaScript skills are limited, and my experience has been ...