如何使用DOM(*object*.style)更改iframe的灰度



按下某个按钮后,我需要将灰度更改为iframe的100%。这是我代码的一部分的基本版本:

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?*);
}

提前感谢!

您可以使用filter CSS属性。

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

另请参阅:灰度

最新更新