From 49a64db1e2a423886fd3327754755e06f645509e Mon Sep 17 00:00:00 2001 From: camenduru Date: Wed, 26 Oct 2022 03:51:24 +0300 Subject: [PATCH] fix get from label not img.src --- javascript/artists_to_study.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/javascript/artists_to_study.js b/javascript/artists_to_study.js index c460156..da22d0c 100644 --- a/javascript/artists_to_study.js +++ b/javascript/artists_to_study.js @@ -6,9 +6,10 @@ document.addEventListener("DOMContentLoaded", function() { gallery.querySelectorAll('button').forEach(el => el.addEventListener( "click", event => { - const img = el.querySelector("img"); - if (img){ - const after_ = img.src.substring(img.src.indexOf('_') + 1); + const div = el.querySelector('div'); + if (div){ + const inside_div = div.querySelector('div').textContent + const after_ = inside_div.substring(inside_div.indexOf('_') + 1); const before_ = after_.substring(0, after_.indexOf('_')); navigator.clipboard.writeText(decodeURI(before_)); }