I'm trying to set the opacity of a div to 0 at first then set it back to 1 again when a for loop finishes, but it stays hidden.. the weird thing is that when ai I fire an alert for the opacity of the div it gives me 1.
document.addEventListener("click",function(event){
const isButton = event.target.id === 'ui-id-2';
const isSpan1 = event.target.innerHTML === '<<';
const isSpan2 = event.target.innerHTML === '>>';
if (isButton || isSpan2 || isSpan1) {
document.querySelector('#base').style.opacity="0";
}
});
browser.storage.local.get({obj:""},function(result){
var username=result["obj"][0].name.split(" ")[0];
if(result["obj"].length>0){
document.querySelector("#ui-id-2").onclick=function(){
updateurl(username);
}
if(document.querySelector("li").getAttribute("aria-selected") != "false")
{
updateurl(username);
}
if(document.querySelectorAll("li")[1].getAttribute("aria-selected") != "false")
{
var win;
var percentinput;
var thisInput;
var percent;
var thisOutput;
var newoutput;
for(var i=18;i<=139;i=i+11){
win=document.querySelectorAll("td")[i].textContent;
for(var j=0;j<result["obj"].length;j++){
if(parseFloat(win).toFixed()==result["obj"][j].input){
thisInput=result["obj"][j].input;
thisOutput=result["obj"][j].output;
percentinput=(parseFloat(thisInput)/100);
percent=percentinput*parseFloat(thisOutput);
newoutput=parseFloat(thisInput)-percent;
newoutput=Math.ceil(newoutput / 5) * 5;
newoutput=newoutput.toFixed(2);
document.querySelectorAll("td")[i].textContent=newoutput;
}
}
//this is the line that i want it to work
if(i==139) document.querySelector('#base').style.opacity="1";
}
}
}
});
I don't know if it helps, but better solution that should work is like if you create class
.hidden {
display : none;
}
and just toggle/add/remove this class from/to your element
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.