我有以下代码

var addressPopupMenu = window.createPopup();
function showAddressPopup() {
    var popup = document.getElementById('addressFullSpan');

    popupMenuBody = popupMenu.document.body;
    popupMenuBody.style.backgroundColor = "#336699";
    popupMenuBody.style.border = "solid 2px; white";
    popupMenuBody.style.fontSize="130%";
    popupMenuBody.style.color="white";
    popupMenuBody.style.padding="10px";
    popupMenuBody.style.paddingLeft="30px";

如您所见,我正在重复popupMenuBody.style。如何给popupMenuBody.style一个CSS类,这样我就不必在每次弹出窗口时都重复此步骤

编辑:不起作用

我添加了popupMenuBody.className = "popups";
.popups
    {
        background-color: #29527A;
        border: solid 2px; white;
        fontSize:120%;
        pcolor:white;
        padding:10px;
        paddingLeft:30px;
        textTransform:capitalize;
    }

也可以,我将.css包含在我的页面中,其他地方在页面上

最佳答案

popupMenuBody.className = "class_name";

09-11 19:02