Extention Tag
var json; function getIndex(value, arr, prop) { for(var i = 0; i < arr.length; i++) { if(arr[i][prop] === value) { return i; } } return -1; //値が存在しなかったとき } function a(){ fetch(DATA_URL).then(function(response) { return response.json(); }).then(function(jsonData) { json = jsonData; }); } window.onmousemove = function(){ var ele = document.querySelector("div.page-tags > span > a:hover"); if (ele){ document.getElementById("result").innerHTML = ele.textContent; var index = getIndex(ele.textContent,json, "tag"); console.log(index); if(index!=="-1"){ console.log(json[index].discription); }else{} }else{} }
ページリビジョン: 5, 最終更新: 12 Mar 2022 12:58