Hovering one item to display the child in another div

SirThanksALot

I ran into a problem and couldn't find an easy solution. I have a couple of tags which have an img assigned to them and I would like that their respective image is displayed in another div, when I hover over it or click the tag. At the moment the images will be shown, but at the location of the hover tag.

Jquery or Js is also an option :)

EDIT As of now the IMG is shown in the left box and I want to be displayed inside the right box on hover. Preferable would be if it would also work with onClick so it stays when I move my mouse away.

There are multiple images (about 100 different ones)

I will provide some code below

.container {
  display: flex;
  width: 100%;
  height: 500px;
}

.left {
  width: 50%;
  height: 500px;
}

.right {
  width: 50%;
  height: 500px;
}

figref:hover img {
  visibility: visible;
  display: block;
  box-shadow: 2px 2px 4px black;
}

figref img {
  display: none;
}
<div class="container">
  <div class="left">
    lorem ipsum delum loresd a sadk kdkas l ldpalo ea ld apsld a
    <figref idref="f0001">
      FIG. 1A <!--ATM When I hover this the Image is displayed below-->
      <img class="normal" src="./images/imgf0001.png">
    </figref>
    <figref idref="f0002">
      FIG. 2A 
      <img class="normal" src="./images/imgf0002.png">
    </figref>
    lorem ipsum delum loresd a sadk kdkas l ldpalo ea ld apsld a
  </div>
  <div class="right"> <!--Here is where the image should be displayed when I hover the figureref-->
  </div>
</div>

jeremy-denis

oen way can be to :

  1. search for the img inside the figRef element
  2. copy the img in the innerHTML of right panel

document.querySelectorAll('figref').forEach(function(fig) {
fig.addEventListener('mouseover', function (e) {
  var target = e.target || e.srcElement;
  document.querySelector('.right').innerHTML = target.querySelector('img').outerHTML;
});
});
.container {
  display: flex;
  width: 100%;
  height: 500px;
}

.left {
  width: 50%;
  height: 500px;
}

.right {
  width: 50%;
  height: 500px;
}

figref img {
  display: none;
}
<div class="container">
  <div class="left">
    lorem ipsum delum loresd a sadk kdkas l ldpalo ea ld apsld a
    <figref idref="f0001">
      FIG. 1A <!--ATM When I hover this the Image is displayed below-->
      <img class="normal" src="./images/imgf0001.png">
    </figref>
    lorem ipsum delum loresd a sadk kdkas l ldpalo ea ld apsld   
   <figref idref="f0002">
      FIG. 2A <!--ATM When I hover this the Image is displayed below-->
      <img class="normal" src="./images/imgf0002.png">
    </figref>a
  </div>
  <div class="right"> <!--Here is where the image should be displayed when I hover the figureref-->
  </div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Display DIV when hovering another DIV's child CSS

change css of one div by hovering on another div

How to display a div when hovering over another div

CSS hovering with in a child div

jQuery hovering over one div to trigger changes in another div

Changing the style of one div when hovering over another

Trying to get div element to move while hovering another one

how to hide one div and hide another on hovering image or text?

Child div jumping from one div to another

Hilighting parent item while hovering child item

Hover on one div to display another div

Dragging item from one div to another and sorting

How do add a class to another div, when hovering over one div?

Why is one child div pushing pushing another child down below it?

How to display div with hovering on a nested div?

Display pointer cursor when hovering paperjs item

Display three links when hovering on another link

display an element when hovering on another element

Hovering over one element changes another?

Hovering over image and displaying text in another div

Hovering over 1 div to change content in another

Affect another div when hovering CSS

Display only one list item at the center of the <div> with overflow:hidden

fadeIn each child div of each div while hovering

keep parent css when hovering over child item

How to display child div on the end of parent flex row div and another two divs on the start of parent div?

how to hide one div and display another on button click event in MVC

Increase a width of a certain div by 10% while hovering on another div

Change the Brightness of a div when hovering over another div

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive