1
<head>
    <style>
        img {
            opacity: 0.5;
        }
    </style>
</head>

This is a part of my HTML file. How do I change the value of the opacity using JavaScript?

1 Answer 1

5

you can use style like:

var imgs = document.querySelectorAll("img");
for(let i = 0; i < imgs.length; i++){
  imgs[i].style.opacity = 1
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.