簡體   English   中英

如何在JavaScript函數中增加單選按鈕的文本大小

[英]how to increase text size of radio button in javascript function

我必須增加單選按鈕的文本大小。 我在javascript函數中調用了這些單選按鈕。

function renderQuestion(){
    test = _("test");
    if (pos >= questions.length) {
        test.innerHTML = "<h2>correct</h2>";
        _("test_status").innerHTML = "Quiz 1 Completed";
        pos = 0;
        correct = 0;
        return false;
    }

    _("test_status").innerHTML = "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Question " + (pos + 1) + " of " + questions.length;
    question = questions[pos][0];
    chA = questions[pos][1];

    test.innerHTML = "<h3>" + question + "</h3>";
    test.innerHTML += "<input type='radio' name='choices' value='A'>" + chA + "<br>";// **need to increase the size of text**
    test.innerHTML += "<button onclick='checkAnswer()'>NEXT</button>";
}

檢查這可以有任何幫助。

請更換您的線

test.innerHTML += "<input type='radio' name='choices' value='A'>" + chA + "<br>";

test.innerHTML += "<input type='radio' name='choices' value='A'><span style='font-size : 20px;'>" + chA + "</span><br>";

這里style='font-size : 20px;' 可用於增加或減少所需的字體大小

您應該在標簽上添加標簽:

test.innerHTML += '<input type="radio" id="choices" name="choices" value="A"><label for="choices">' + chA + '</label><br>';

您可以在標簽中添加一個類,並通過CSS來簡單地增加其字體大小。

另外,帶有for=""屬性的標簽將允許單擊該標簽以選中具有相同ID id="choices"的框。

請注意,我已經更改了引號。 由於通常在HTML屬性上保留默認的"標記更為干凈。但這只是個人喜好。

暫無
暫無

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

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