簡體   English   中英

使用 javascript 更改文本顏色的奇怪問題

[英]Weird issue with changing text color using javascript

我有一個奇怪的問題,我似乎無法解決。 如果有錯誤,我會嘗試顯示有錯誤的文本(這確實有效),但是,我希望該文本為紅色,並且我嘗試過的所有操作均無效。

我試圖在要更改 innerHTML 的 div 標簽中將顏色設置為紅色,但這不起作用。 我也嘗試在 javascript 中更改它,不起作用。 並且還在我添加的 h2 標簽中添加一個樣式參數,你猜對了,不起作用。

任何想法是什么問題?

JS

    var error_handle = document.getElementById('error-handle');

.then(
    (message) => {if(message != "OK"){
        error_handle.innerHTML = "<h4  id ='errortag';'>An error has occured while sending the email. Please try again.</h4>"
        error_handle.style.color = "#e3121d";

        confirmation.innerHTML = "";
        button.value = "Send Message";

    }});

HTML

<div id ="error-handle">

</div>

CSS

#error-handle {color: "r#e3121d'"; background-color: '#e3121d';}
#errortag{font-family: "Mukta Mahee", arial, sans-serif;color: '#e3121d';}

在您的 CSS 中更改: "r#e3121d'"; "#e3121d";

PS這是我第一次回答關於Stackoverflow的問題,如果我錯了請糾正我:)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM