There are a lot of pictures with a single crypt_img class, with a hover for which you need to show the corresponding block with the crypt_text class, which are also several, how is this implemented in js? Saw a couple of times that with the help val (), eq () and attr (), but very little knowledge to implement it and write the code

    1 answer 1

    Do you really need to use JS, or maybe just use CSS? It is possible in more detail where the text block should be displayed.

    .photo { display: inline-block; /* Π‘Ρ‚Ρ€ΠΎΡ‡Π½ΠΎ-Π±Π»ΠΎΡ‡Π½Ρ‹ΠΉ элСмСнт */ position: relative; /* ΠžΡ‚Π½ΠΎΡΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΠ΅ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ */ } .photo:hover::after { content: attr(data-title); /* Π’Ρ‹Π²ΠΎΠ΄ΠΈΠΌ тСкст */ position: absolute; /* ΠΠ±ΡΠΎΠ»ΡŽΡ‚Π½ΠΎΠ΅ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ */ left: 20%; top: 30%; /* ПолоТСниС подсказки */ z-index: 1; /* ΠžΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅ΠΌ подсказку ΠΏΠΎΠ²Π΅Ρ€Ρ… Π΄Ρ€ΡƒΠ³ΠΈΡ… элСмСнтов */ background: rgba(255,255,230,0.9); /* ΠŸΠΎΠ»ΡƒΠΏΡ€ΠΎΠ·Ρ€Π°Ρ‡Π½Ρ‹ΠΉ Ρ†Π²Π΅Ρ‚ Ρ„ΠΎΠ½Π° */ font-family: Arial, sans-serif; /* Π“Π°Ρ€Π½ΠΈΡ‚ΡƒΡ€Π° ΡˆΡ€ΠΈΡ„Ρ‚Π° */ font-size: 11px; /* Π Π°Π·ΠΌΠ΅Ρ€ тСкста подсказки */ padding: 5px 10px; /* Поля */ border: 1px solid #333; /* ΠŸΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ Ρ€Π°ΠΌΠΊΠΈ */ } 
      <div class="photo" data-title="Π­Ρ‚ΠΎ Apple!"><img src="https://infoday.site/wp-content/uploads/2018/05/apple-03.jpg" alt=""></div> 

    • prnt.sc/k9xwj6 - Dmitry Noskov
    • Here you need when you hover on the appropriate cryptocurrency, so that the corresponding caption climbs, cryptocurrency images have the same class crypt_img, tooltips have crypt_text - Dmitry Noskov
    • And that version with CSS that I wrote above does not suit you? Should I use JS? - Lukas