本文介绍了我想使用javascript更改与单选按钮关联的文本样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如问题中所述
i想要改变与固定单选按钮相关联的文本的样式或特别颜色
i知道如何使用标签,我可以更改特定单选按钮的文本使用
As told in the question
i want to change the style or particularly color of the text associated with a fixed radio button
i know how to use label and i can change the text of a particular radio button using
document.getElementById('ques29').firstChild.nodeValue
for <input type="radio" name = "q30" value="D"><label id="ques29">(D) work function</label>
所以任何人都可以指导我如何更改文本的颜色
so can anyone guide me on how to change the color of the text
推荐答案
<style>
.mystyle {
background-color: coral;
font-size: 25px;
color: green;
}
</style>
第2步:在下面添加javascript代码
Step2: Add below javascript code
<script>
var ele = document.getElementById('ques29');
ele.setAttribute('class', 'mystyle');
</script></script>
注意:这里是HTML控制单选按钮的'ques29'ID。您可以实现相同的任何HTML控件。
Note: Here 'ques29' ID of HTML Control radio button. You can implement the same any HTML control.
这篇关于我想使用javascript更改与单选按钮关联的文本样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!