在amx中单击按钮时更改整个背景颜色

change whole background color while clicking button in amx

本文关键字:背景 颜色 amx 单击 按钮      更新时间:2023-09-26

在AMX页面我有2个命令按钮。如果我点击第一个命令按钮,我想为整个页面改变一个背景颜色。如果我点击第二个,我想应用一些不同的背景颜色。我正试图插入javascript来做到这一点。但这行不通。请帮帮我,我该怎么做?

<?xml version="1.0" encoding="UTF-8" ?>
<amx:view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amx="http://xmlns.oracle.com/adf/mf/amx"
          xmlns:dvtm="http://xmlns.oracle.com/adf/mf/amx/dvt">
    <amx:panelPage id="pp1">
        <amx:facet name="header">
            <amx:outputText value="Home" id="ot1"/>
        </amx:facet>
         <amx:commandButton text="Red" id="red" styleClass="blue-background">
            <amx:validationBehavior id="abc"/>
        </amx:commandButton>
        <amx:outputText value="Color" id="color"/>        
        <amx:commandButton text="Green" id="green" styleClass="green-background"/>       
    </amx:panelPage>
</amx:view>

以上代码是我的AMX页面代码。javascript代码是

$(function(){
     $("#red").on("click", function(){
        alert("clicked");        
     });
         $("#green").on("click", function(){
        alert("clicked second....");         
     });
});

我不知道AMX,但这就是我们在javascript中的做法:

document.getElementById('green').onclick=function(){
            document.body.style.background='green';
                }
document.getElementById('red').onclick=function(){
        document.body.style.background='red';
    }