【问题标题】:Changing color of radiobutton inside jqueryui buttonset更改jquery ui按钮集中单选按钮的颜色
【发布时间】:2012-05-03 09:48:41
【问题描述】:

我有一个 jquery 单选按钮,我用 Jqueryui 的按钮集设置了样式:

<link type="text/css" href="jqueryUI1.8.16/css/smoothness/jquery-ui-1.8.16.custom.css" 
rel="stylesheet"/>  
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="jqueryUI1.8.16/js/jquery-ui-1.8.16.custom.min.js">
</script>

<script type="text/javascript">

$(document).ready(function(){

    $("#atable tr").buttonset();


});

</script>
</head>

<body>
<table id="atable" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td class="aspmnr">1</td>
    <td class="aspm">Test text</td>
    <td class="aradio">
      <input id="asp11" name="asp1" type="radio" value=0>
      <label for="asp11">0</label></td>
    <td class="aradio">
      <input id="asp12" name="asp1" type="radio" value=1>
      <label for="asp12">1</label></td>
    <td class="aradio">
      <input id="asp13" name="asp1" type="radio" value=2>
      <label for="asp13">2</label></td>
    <td class="aradio">
      <input id="asp14" name="asp1" type="radio" value=3>
      <label for="asp14">3</label></td>    
  </tr>
</table>

我希望能够更改其中一个按钮的背景颜色,例如:

$("#asp11").css("background-color","#aaaaa5");

我也尝试将 css 应用于标签,但背景颜色会在瞬间变回默认值。 我想避免弄乱 jqueryui 的原始样式表。

有人知道如何更改按钮的背景颜色吗?

【问题讨论】:

    标签: jquery jquery-ui button colors


    【解决方案1】:

    试试这个。

    $(".aradio label").css("background-color","#aaaaa5");
    $(".aradio label").css("background-image","none");

    $(".radio label:first").css("background-color","yellow");
    $(".aradio label:first").css("background-image","none");

    $(".radio label").eq(1).css("background-color","re​​d");
    $(".aradio label").eq(1).css("background-image","none");

    【讨论】:

    • 做到了!非常感谢。因为我是新来的,所以我不能投票给你。
    • 继续问你问题。在这里您可以找到最佳解决方案。谢谢
    【解决方案2】:

    您必须删除标签上的背景图片,执行标签上的所有 css 代码,例如 0

    $("#lblforasp11").css("background-color", "#aaaaa5");
    $("#lblforasp11").css("background-image", "none");
    

    【讨论】:

      猜你喜欢
      • 2011-05-22
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-11-20
      • 2015-06-27
      • 2011-04-19
      • 2014-05-27
      相关资源
      最近更新 更多