简体   繁体   中英

How do I change the grayscale of an iframe using DOM (*object*.style)?

I need to change the grayscale to 100% of an iframe after a certain button is pressed. Here is a basic version of a part of my code:

HTML:

                    <tr>
                        <td>
                            <p class = "text">
                                Would you like to turn the colors into black and white?
                            </p>
                        </td>
                        <td>
                            <input type = "radio" id = "blackandwhiteyes" name = "blackandwhite" value = "blackandwhiteyes" required>
                        </td>
                        <td>
                            <input type = "radio" id = "blackandwhiteno" name = "blackandwhite" value = "blackandwhiteno" required>
                        </td>
                    </tr>

JavaScript:

blackandwhiteyes.onclick = function () {
    numiframe.style.(*What do I enter here to make the grayscale change?*);
}

Thanks in advance!

You can use the filter CSS property.

numiframe.style.filter = "grayscale(100%)";

See also: grayscale

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM