使用JavaScript将颜色分配给RadioButtonList的单选按钮文本 [英] Assigning color to a radiobutton text of a RadioButtonList using javascript
本文介绍了使用JavaScript将颜色分配给RadioButtonList的单选按钮文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们...谁能告诉我如何使用JavaScript将颜色分配给RadioButtonList的单选按钮文本吗?
我正在获取如下所示的特定单选按钮..
Hi Friends... Can any one tell me how to assign color to a radiobutton-text of a RadioButtonList using javascript?
Iam getting the particular radio buttons as below..
for (i = 0; i < document.forms[0].elements.length; i++) {
elm = document.forms[0].elements[i];
if (elm.type == 'radio') {
if (elm.checked) { cmpIdRange = elm.value; break; }
}
}
我是这样尝试的.
I tried like this..
document.getElementById(elm.id).style.color = "green";
但是我没有得到结果...请告诉我任何解决方案.
在此先感谢...
But im not getting the result... Please tell me any solution.
Thanks in advance...
推荐答案
嗨
尝试以下
Hi
try the following
<asp:RadioButton ID="rbtnTest" runat="server" onclick="changecolor(this);" />
Javascript:
Javascript:
function changecolor(ctrl) {
ctrl.style.backgroundColor = "Red";
ctrl.nextSibling.style.color= "Orange";
}
这篇关于使用JavaScript将颜色分配给RadioButtonList的单选按钮文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文